Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
gettext-translator
Advanced tools
Javascript gettext translator. Use gettext/gettext PHP library to generate and modify the messages.
Supports:
npm install gettext-translator
Use the Json generator of the gettext/gettext library to export the translations to json:
use Gettext\Translations;
//Load the po file with the translations
$translations = Translations::fromPoFile('locales/gl.po');
//Export to a json file
$translations->toJsonFile('locales/gl.json');
Load the json file in your browser (for example, using webpack) and use it
var Translator = require('gettext-translator');
var translations = require('locales/gl.json');
var i18n = new Translator(translations);
console.log(i18n.gettext('hello world')); //ola mundo
This library includes sprintf dependency implemented in the short methods like __
, n__
, etc...:
i18n.__('Hello %s', 'world'); //Hello world
i18n.n__('One comment', '%s comments', 12, 12); //12 comments
Long method | Short + sprintf | description |
---|---|---|
gettext | __ | Returns a translation |
ngettext | n__ | Returns a translation with singular/plural variations |
dngettext | dn__ | Returns a translation with domain and singular/plural variations |
npgettext | np__ | Returns a translation with context and singular/plural variations |
pgettext | p__ | Returns a translation with a specific context |
dgettext | d__ | Returns a translation with a specific domain |
dpgettext | dp__ | Returns a translation with a specific domain and context |
dnpgettext | dnp__ | Returns a translation with a specific domain, context and singular/plural variations |
FAQs
Javascript gettext translator
We found that gettext-translator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.