jfTranslations
Simple class for translations system.
See here for data structure of parsed JSON translations files.
Usage
Examples
// File: translations/en.ui.json "charset" : "utf-8" "translations" : "" : "Hola {name}, bienvenido a {site}" : "msgstr" : "Hello {name}, welcome {site}"
// You can use it as singleton const translations = ;// Or using new operator. const Translations = ;const translations = ;//translationspoDir = __dirname + '/translations';translations;console; // Hello Guest, welcome home
Plurals
const count = 20;console; // You have 20 items in your cart
Mixing formats
You can mix printf
-like format with context placeholders.
printf
placeholders are replaced before context placeholders and their
order is important. Context placeholders order is not important because
each context is merged.
console; // First file `file1.js` has 1234 bytes and second file `file2.js` has 4567 bytes.',