I'm working on JavaScript based web app. I want JSON based multiple language integration. Which one is best library (without jQuery) to provide multi language support?
Asked
Active
Viewed 8,058 times
-1
-
I think this link can help you http://stackoverflow.com/questions/228835/best-practice-javascript-and-multilanguage – nhannv Jan 05 '16 at 07:39
2 Answers
1
Actually working with angularjs and angular-translate has covered all my needs on that field. You can get the translations from a js or a JSON as you please. It sometimes has problems with scopes and cached translations but everything is easily solvable. Have a look at it: http://angular-translate.github.io/

Imjustsaying
- 11
- 1
-
If you know about AngularJs and love it, this library is nice to use... . I Love this.Thx – Milad Ghiravani Oct 01 '16 at 16:30
1
You can do it without any library, but just using js objects:
var hi = {"english": "hi",
"italian": "ciao",
"spanish": "hola"};
var LANGUAGE = "spanish"; // choose language with your code
alert(hi[LANGUAGE]);
Returns
hola
Moreover, you could use different files for each language:
// spanish.js
texts = {"hi": "hola",
"howareyou": "¿Que tal?"};
// italian.js
texts = {"hi": "ciao",
"howareyou": "Come stai?"};
// main html file (for example):
<script src="italian.js"></script> <!-- choose language file with your code -->
<script>
alert(texts["howareyou"]);
</script>
Returns
Come stai?
However, there are many ways to do this, as explained in this answer.
P.S. Sorry for any language mistake :)

Community
- 1
- 1

moonknight
- 334
- 1
- 7