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.
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.
Share Improve this question edited Dec 4, 2012 at 0:37 insomiac asked Dec 4, 2012 at 0:19 insomiacinsomiac 5,6648 gold badges47 silver badges73 bronze badges 6- 4 Localization is not an inherent feature in browsers, JavaScript, or the HTML specification. In other words, you need to manage localization on your own (usually detecting language on the server side and emitting the appropriate strings in the resulting HTML). Are you doing something specific where this expectation is met? If so, provide more details so we can help. – moribvndvs Commented Dec 4, 2012 at 0:26
- I need to see the labels "OK" and "Cancel" translated into other language. I read this question stackoverflow./questions/1901745/… but this doesnt work for me. – insomiac Commented Dec 4, 2012 at 0:29
-
1
Ah, I see, a browser-generated dialog ala
confirm
oralert
. – moribvndvs Commented Dec 4, 2012 at 0:34 - Yes. I am talking about confirm dialog which is from javascript. In confirm box, I always see the confirmation buttons in english instead of the browser language. – insomiac Commented Dec 4, 2012 at 0:36
- Worksforme. If I change the language setting of Chrome to German, I see "OK" and "Abbrechen". Where did you change it, did you restart Chrome? – Bergi Commented Dec 4, 2012 at 1:33
1 Answer
Reset to default 12There 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.
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.