JavaScript确认按钮的本地化 [英] Localization for javascript confirmation buttons

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

问题描述

我正在使用JavaScript中的确认"框.对于所有浏览器,我发现更改浏览器的语言时,确认"框中的确认按钮语言不会更改.我通过将语言更改为法语在chrome,firefox上进行了测试.但是按钮标签未翻译. 确定"和取消"的标签不会更改为其他语言.

I am working with Confirm box in javascript. For all browsers i found that when change the language of the browser, the confirmation button language in Confirm box doesn't change. I tested on chrome, firefox by changing the language to french. But the buttons label is not translated. Label of "OK" and "Cancel" doesn't change to other language.

请注意:我正在尝试在确认框中看到本地化的字符串.

Please Note : I am trying to see the localized string on confirmation box.

推荐答案

无法使用confirm()alert() JavaScript函数并获得可靠的结果.它仅取决于Web浏览器的语言,即程序,而不是您的首选语言.
首选语言用于告诉Web服务器,您相对于网页语言的偏好是什么.

There is no way to use confirm() and alert() JavaScript functions and have reliable results. It simply depends on the language of web browser, that is the program, not your preferred language.
The preferred language is used to tell the web server what is your preference in reference to the web page language.

您会问,如何本地化确认或消息对话框?
好吧,摆脱他们.相反,请使用 jQuery UI对话框的模式确认,并按照常规的JavaScript字符串资源本地化方法进行操作.
这是将确认对话框的标题和按钮可靠地转换为Web应用程序语言的唯一方法.

So how to localize the confirmation or message dialogs, you would ask?
Well, get rid of them. Instead, please use jQuery UI Dialog's modal confirmation and follow your regular localization method for JavaScript string resources.
It is the only way to have confirmation dialog's titles and buttons translated reliably to the language of your web application.

这篇关于JavaScript确认按钮的本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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