PHP Classes

File: test/js/test.js

Recommend this page to a friend!
  Classes of Nikos M.   Localizer   test/js/test.js   Download  
File: test/js/test.js
Role: Auxiliary data
Content typex: text/plain
Description: Auxiliary data
Class: Localizer
Get localized texts in PHP, JavaScript and Python
Author: By
Last change:
Date: 3 months ago
Size: 1,304 bytes
 

Contents

Class file image Download
"use strict"; const Localizer = require('../../src/js/Localizer.js'); const l10n = new Localizer(); // setup supported locales l10n.locale('en', {}); l10n.locale('el', { 'I want to say {0}' : '???? ?? ?? {0}', 'hello to you' : '???? ?? ????', 'hello to all' : '???? ?? ?????', '@' : { // specific context 'ctx1' : { 'hello to you' : '???? ?? ???? ????', }, }, }); // set current locale l10n.locale('el', true); // UTF8 BOM const UTF8_BOM = Buffer.from([0xEF,0xBB,0xBF]); require('fs').writeSync(process.stdout.fd, UTF8_BOM, 0, UTF8_BOM.length); console.log('Localizer.VERSION = ' + Localizer.VERSION); console.log(l10n.locale()); console.log(l10n.l('hello to you')); console.log(l10n.l('hello to all')); console.log(l10n.l('hello to you', '???? ?? ????')); console.log(l10n.l('hello to all', '???? ?? ?????')); console.log(l10n.l('I want to say {0}', [l10n.l('hello to you')])); console.log(l10n.l('I want to say {0}', [l10n.l('hello to all')])); console.log(l10n.ln(1, 'hello to you', 'hello to all')); console.log(l10n.ln(2, 'hello to you', 'hello to all')); console.log(l10n.l('hello to you', '???? ?? ???? ????')); console.log(l10n.l(['hello to you','ctx1']));