Singleton

Version 0.6

One-fits-all Internationalization Solution

Integrate Singleton in Go App

Requirements

  • Go 1.13 or higher

Install Singleton client package

go get -u github.com/vmware/singleton@v0.7.1-Singleton-Go-Client

Change v0.7.1-Singleton-Go-Client to the version of Singleton client you will use.

Sample code

package main

import (
  "fmt"

  sgtn "github.com/vmware/singleton"
)

func main() {
  cfg := &sgtn.Config{
    ServerURL:         "https://localhost:8090",
    LocalSourceBundle: "./sources",
    DefaultLocale:     "en",
    SourceLocale:      "en",
  }
  sgtn.Initialize(cfg)
  trans := sgtn.GetTranslation()

  // Get translation of a string
  message, err := trans.GetStringMessage("SgtnTest", "1.0.0", "zh-Hans", "sunglow", "application.title")
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Printf("\nThe translation is '%s'.\n", message)
}
Last updated on 11 May 2023
Published on 11 May 2023
 Edit on GitHub