Skip to content

Latest commit

 

History

History
121 lines (71 loc) · 3.21 KB

README.rst

File metadata and controls

121 lines (71 loc) · 3.21 KB

image

image

image

image

image

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