Skip to content
helloworld-catPublic

About

Simple and easy lib. to manage translations and texts, with cache, in Go project.

Topics

Resources

Stars

13 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

About

Simple and easy lib. to manage translations and texts, with cache, in Go project.

Installation

go get -u github.com/pagedegeek/textsbox

Usage

// main.go
package main

import (
        "github.com/pagedegeek/textsbox"
)

func main() {
        tb := textsbox.New()

        tb.LoadFile("./config/locales/en.yml")
        tb.LoadFile("./config/locales/fr.yml")

        tb.AddKeyAlias("en", "en-En")
        tb.AddKeyAlias("fr", "fr-Fr", "fr-FR")

        // ...
        // locale := session.Get("locale") // can be: en, en-En, fr, fr-Fr, fr-FR

        txt, _ := tb.Find(locale, "messages.welcome")
        welcomeMsg := txt.(string)
        view.render(welcomeMsg)
}
# config/locales/en.yml
en:
  messages:
    welcome: Hello World !
# config/locales/fr.yml
fr:
  messages:
    welcome: Bonjour tout le monde !

Other features

Load YAML content

tb.LoadFile("...") // load from file
tb.Load(reader) // load from io.Reader

Reset cache

tb.ResetCache()

About

Simple and easy lib. to manage translations and texts, with cache, in Go project.

Topics

Resources

Stars

13 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages