8000
Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://travis-ci.org/siongui/gopherjs-i18n.svg?branch=master https://goreportcard.com/badge/github.com/siongui/gopherjs-i18n

gettext function in your browser.

This package includes offline code to convert PO to JSON, and runtime code to translate strings.

Development Environment:

Install

Install package:

go get -u github.com/siongui/gopherjs-i18n

Online Translating Website

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 Preparing Translation Data

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:

  • domain: usually messages
  • localedir: the directory where you put PO files
  • jsonPath: output path of JSON file

UNLICENSE

Released in public domain. See UNLICENSE.

References

[1][Golang] gettext Function on Frontend (Browser) by GopherJS
[2][Golang] GopherJS Synonyms with JavaScript
[3]

golang list file in directory

ReadDir - ioutil - The Go Programming Language

[4]

golang path join

path - The Go Programming Language

About

i18n support in GopherJS

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0