node-gettext-sprintf
A combination of node-gettext and sprintf
Installation:
npm install node-gettext-sprintf
Usage:
"use strict";var fs = ;var getText = ; // setup the 'test' languagevar getText = ; /*Given a PO in this form: msgid ""msgstr """Language: test0""MIME-Version: 1.0""Content-Type: text/plain; charset=UTF-8""Content-Transfer-Encoding: 8bit""Plural-Forms: nplurals=2; plural=(n != 1);" msgid "Simple string"msgstr "Simple string translated" msgid "1 string, 1 int place-holder: %s, %d"msgstr "1 string, 1 int place-holder: %s, %d translated" msgid "Simple string singular"msgstr[0] "Simple string translated"msgstr[1] "Simple string translated plural" msgid "Simple string singular int place-holder: %d"msgstr[0] "Simple string translated int place-holder: %d"msgstr[1] "Simple string translated plural int place-holder: %d" msgctxt "Test Context"msgid "Simple string in context"msgstr "Simple string in context translated" msgctxt "Test Context"msgid "Simple string singular in context int place-holder: %d"msgstr[0] "Simple string in context translated int place-holder: %d"msgstr[1] "Simple string in context translated plural int place-holder: %d"*/ // load the 'test' languagelanguageFns = ; languageFns;// returns "Simple string translated" languageFns;// returns "1 string, 1 int place-holder: test-string, 30 translated" languageFns;// returns "Simple string translated plural" languageFns;// returns "Simple string translated plural int place-holder: 20" languageFns// returns "Simple string in context translated" fns// returns "Simple string in context translated plural int place-holder: 20"
The following standard gettext methods are also supported:
dgettext (getSingularText)
dpgettext (getSingularTextInContext)
dngettext (getSingularOrPluralText)
dnpgettext (getSingularOrPluralTextInContext)