3

I get a Swedish "send"-button on a site build in English on my Swedish Win7. My English users won't probably even notice that once it's uploaded but Santa Clause knows it and keeps a list of when I've been bad. So I went and added "lang" attribute as follows.

<input id="submit" type="submit" lang="en" />

And guess what, it still shows in Swedish. Why?! And how to force the desired text?

Should I explicitly specify the string to be displayed? I'd prefer to set the text given the current (or by me specified) language.

1
  • Please check the language locale which has set in the request? Commented Jul 30, 2012 at 9:54

3 Answers 3

4

As @Chris explains, the lang attribute is declarative: it tells what language the content and the attributes of an element are, instead of translating anything.

You can, and generally should, set the text to be displayed in a submit button using the value attribute, e.g. <input id="submit" type="submit" value="Send" />.

Sign up to request clarification or add additional context in comments.

1 Comment

OK. I thought it was a better code not to specify the string explicitly. But if you say it is, i'm happy because that actually allows me for a better control over the looks. Now, i won't have to worry about "send" varying between different browsers (which is the case in some languages - Chrome says one thing, FF an other).
2

The lang attribute is not used to force translation of text. It is a general attribute to provide metadata (http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang).

In theory a browser could use this in some contexts to do translation but I don't think it ever does. More probably the language of your submit button is to do with the installed language of your computeror possibly browser or something similar like that.

If your site is generally multilingual then I would suggest using the same translation code to translate this explicitly. If it is not multilingual then just let the browser/user worry about it.

1 Comment

Sorry, looking at the other answer I hadn't realised that you were explicitly avoiding specifying the display string. What I was meaning was that if you were getting the english/swedish/whatever text for the rest of the website by some process then just get the "submit" text the same way and put it on the button.
0

You can customize the content by using the value attribute.
see more: https://www.w3schools.com/tags/att_button_value.asp

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.