在JavaScript文件处理国际化文件、JavaScript

2023-09-10 17:54:38 作者:散了吧算了吧

例如,执行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.

 
精彩推荐
图片推荐