多语种应用在Angularjs或离子框架 [英] Multilingual App in Angularjs or in Ionic Framework
问题描述
我很新的这两个Angularjs和离子框架。我从微软背景的。
I am very new to both Angularjs and Ionic Framework. I coming from Microsoft background.
我试图让应用在3种语言(英语,阿拉伯语和法语)。正如我告诉你,我从微软背景的,我想在多语种翻译应用程序,我们使用的资源文件,并在我们的.NET code根据语言环境.NET的方式。至于例如:
I am trying to make app in 3 languages (English, Arabic and French). As I told you that I am coming from Microsoft background I am thinking in .net way that for multilingual apps translation we use resource file and in our .net code as per language environment. As for example
的http://www.$c$cproject.com/Tips/580043/How-to-make-a-multi-language-application-in-Csharp
有没有办法做同样的事情Angularjs或离子框架
Is there any way to do same thing Angularjs or Ionic Framework
推荐答案
像这样的东西可以帮助加载含有键和含例如EN-US.json值语言文件语言{
NAME:姓名,
EMAIL:电子邮件}
和机能缺失加载这些
Something like this could help to load language from language files containing keys and values e.g en-US.json containing { "NAME": "Name", "EMAIL": "Email"} and afunction to load these
// load message from language file on basis of file name
function loadLanguage() {
filePath = "en-US.json";
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
eval('var objLang=' + xmlhttp.responseText);
alert(objLang.EMAIL);
}
}
xmlhttp.open("GET", filePath, true);
xmlhttp.send();
}
这篇关于多语种应用在Angularjs或离子框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!