javascript - Using node-localize -


what best way provide localization node.js , angularjs stack?

i trying provide localization using node-localize module. front end angularjs , node server acts rest service providing json strings.

in documentation of node-localize, written can pass folder , translations.json files used translation. unable working files. should format of translations.json? want pass entire file angular , using filters want implement localization in views (as explained here).

this worked me, use same json pass constructor:

tranlations.js

 var localize = require('localize');   var mylocalize = new localize('./translations/');   console.log(mylocalize.translate("testing...")); // testing...  console.log(mylocalize.translate("substitution: $[1]", 5)); // substitution: 5   mylocalize.setlocale("es");  console.log(mylocalize.translate("testing...")); // pruebas...   mylocalize.setlocale("sr");  console.log(mylocalize.translate("substitution: $[1]", 5)); // замена: 5 

./translations/translations.json

 {      "testing...": {          "es": "pruebas...",          "sr": "тестирање..."      },      "substitution: $[1]": {          "es": "sustitución: $[1]",          "sr": "замена: $[1]"      }  } 

then execute:

node translations.js


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -