da2x / gettext-makejs2

Turns gettext translation files into handy JavaScript object objects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage
gettext-makejs2 <po-files>

Finds all .js files from available gettext .po[t] files. Then finds all strings for each file, and outputs them in their own JavaScript files as named object objects.

The script makes the assumption that the .po string bases are stored in the convention: “language/string_dataset.po” and that the output will be in “language/path-to/original.js”. This was done to work in the context of a W3C Widget package’s locales/ folder. This tool is primarily written to be used with the Opera and W3C Widget Packaging platform (used in widgets and browser extensions for Opera, and other implementations). But the tool is fairly generic and can be used as is for other uses, or adapted for different needs (it’s open source, alright!).

Options (set a environmental variables)

GETTEXT_MAKEJS2_SUFFIX
Add a file name suffix to the output script name. For example, “.i18n” (default unless “OFF”) or “-strings”.

GETTEXT_MAKEJS2_NAME
Name of the object object containing the translations. Default is “i18n”.

Tips: Making the gettext .po[t] files in the first place …

xgettext.pl will extract will extract strings from JavaScript source files that uses the regular _(‘string convention’) without any additional fuss.

24 Ways’ article on JavaScript Internationalization is a great read.

About

Turns gettext translation files into handy JavaScript object objects.

License:Other


Languages

Language:Perl 100.0%