在JavaScript文件处理国际化 [英] Handling i18n in javascript files

查看:138
本文介绍了在JavaScript文件处理国际化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,执行CRUD操作的时候,我的应用程序在很大程度上依赖于使用Ajax。

For example, my app relies heavily on the use of AJAX when doing CRUD operation.

截至目前,信息与此类似硬codeD。

As of now, messages are hardcoded similar to this.

function handleSaveNewMember(xhr, status, args) {  
    if(args.validationFailed || !args.result) {   
    }else{  
        showmsg.show([{summary:'Add New Member', detail: 'Successfully Added New Member', severity: 'info'}]);
    }  
}

但是,如果你部署应用程序,以不同的语言环境?那你怎么处理国际化功能?

But what if you deploy your app to a different locale? Then how do you handle the i18n feature?

我用Primefaces这里顺便说一句。

I used Primefaces here by the way.

推荐答案

这可能不是最好的解决办法,但在过去,我已经基本上链接包含我在code基准字符串常量一个js文件。在负载,我加载相应的js文件对当前文化。确保有某种默认每个常量应该该文件无法加载虽然。

It may not be the best solution, but in the past I've essentially linked a js file that contains string constants that I reference in code. On load, I load the appropriate js file for the current culture. Make sure to have some kind of defaults for each constant should that file not load though.

这篇关于在JavaScript文件处理国际化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆