Skip to content

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

Notifications You must be signed in to change notification settings

helloworld-cat/textsbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

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

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages