I have a web page which has an input type="file" for allowing the user to browse and select a file to upload. My machine's culture is en-GB, the website culture should be nb-NO. How can I tell browsers to localize the button text?

  • Firefox says "Browse..."
  • Safari says "Choose File"

I have tried <html lang="nb-NO"> but the buttons remain in English.

2 answers

This was chosen as the best answer

Browsers automatically localize the text - e.g. a French browser would use naviger.

it gets the settings from the machine locale settings, not the html page.

makes sense really?

So, what I'm saying is that your form elements will change based on the locale of the machine viewing them.

if you want to see what they'd look like you just need to change your locale.

Answered about 10 years ago by Tony Crockford
  • you can simulate the behaviour by changing operating system languages - particularly easy to see in OSX - you just move a language to the top, close and re-open the broaser and all the standard buttons are now in that language. Tony Crockford about 10 years ago
  • That's what I thought, though I've tested on a machine with nb-NO set up as the machine locale and installed Safari 4 on it - the button still says "Choose File". I'd love it if someone knew of a nice big lookup table which showed under what circumstances the text changed. There are many variables: language version of the installed OS, current locale of the OS, language version of the browser, browser, browser version, page language etc... tjrobinson about 10 years ago
  • weird, because my safari flips back and forth between languages nicely. (you have to re-open it between language selections) basically any form control that interacts with the file system will be rendered by the OS AIUI Tony Crockford about 10 years ago
  • I'm running Windows XP, perhaps it works differently. tjrobinson about 10 years ago
  • Ah, probably, Safari for windows won't be as closely tied in... Tony Crockford about 10 years ago
  • I installed the Norwegian language version of Windows XP in a virtual machine, then installed Safari 4, Chrome 2, IE6 and Firefox 3. The Browse... buttons (or Webkit equivalents) are translated into Norwegian as expected. So it seems to be based on the operating system language and browser UI language. tjrobinson about 10 years ago
danwellman 5600

This may depend on the locale setting on the client machine as the browse button is not technically part of the page (even though it's on the page, it's added automatically by the browser and I believe the text on the button varies between browsers too).

If you can localise this button text independantly of the locale setting on the users machine, you'll probably have to configure the server or platform, e.g. this tutorial shows how to set the culture and UI culture for an ASP.NET site

Answered about 10 years ago by danwellman
  • Thanks for the answer. You're right that the locale setting has an influence, see the comments on Tony Crockford's answer for more details. tjrobinson about 10 years ago