gettext function in your browser.
This package includes offline code to convert PO to JSON, and runtime code to translate strings.
Development Environment:
Install package:
go get -u github.com/siongui/gopherjs-i18n
See demo first. Demo code is in example directory.
Wrap the string you want to translate in element with data-default-string attribute containing the un-translated string. For example,
<div data-default-string="Home">Home</div>
or
<span data-default-string="Home">Home</span>
Both are valid for later translation.
offline: example for converting PO to JSON:
package main
import "github.com/siongui/gopherjs-i18n/tool"
func main() {
po2json.PO2JSON("messages", "../pali/common/locale/", "po.json")
}
PO2JSON takes three arguments:
Released in public domain. See UNLICENSE.
[1] | [Golang] gettext Function on Frontend (Browser) by GopherJS |
[2] | [Golang] GopherJS Synonyms with JavaScript |
[3] |
[4] |