What are the differences between the values "en" and "en-BR" of the lang attribute?

Asked

Viewed 11,304 times

12

I was unable to notice any difference between both values in the tests. Does anyone know? To help: the first two characters of the value define the Language Code Reference (ISO 639-1) and the last two, after the separator, identify the Country Code Reference (ISO 3166-1). But when we omit Country Code, what actually changes? I don’t see anything different in IE and Chrome browsers and developers usually don’t inform the country.

2 answers

18


I’ll sum it up nicely, pt indicates Portuguese, regardless of country/region as:

Source: Which countries and Regions Speak English?

  • Brazil
  • Portugal
  • Sao Tome and Principe
  • Angola
  • Mozambique
  • Cape Verde
  • East Timor
  • Guinea-Bissau
  • Equatorial Guinea
  • Macau (Macau)

When we use pt-BR indicate Brazilian Portuguese, as well as pt-PT indica Portuguese de Portugal.

Portuguese as well as English have variations in different countries, indicating the pt-BR, pt-PT, pt, en, en-US, en-GB do not interfere with HTML, are only values to inform which language is, for example some browsers have language detection of the page and they can pass to some plugin this, or a plugin (add-on/extension) can use the attribute directly.

If you place the URL of the page that uses this attribute in http://translate.google.com it will detect that <div lang="pt-BR"></div> uses Brazilian Portuguese (although google does not differ much both).

Others who can usually use this attribute are searchers like Google, Bing, Yahoo, Baidu. Searchers use these attributes to deliver regional and language preference pages of a searcher.

Now speaking only of HTML, the attribute lang regardless of its value, pt or pt-BR does not change anything, the idea of its use is regulate and indicate the types of data for those who are interested, if there is no this attribute plugins, google translator or search engines have more difficulty detecting the language and region of the page.

5

When informing only the language, that content will be used in specific tools configured for that language. When informing the language and the regional dialect the content will be used only in the tool configured for that country. Unless you don’t have this setting, but you do have the language, then he takes advantage of what’s available.

The attribute lang is one that gives semantics to the content, but has nothing important in the presentation.

This technique is little used, although it is useful in several cases and is more necessary every day in several scenarios. Usually the whole page is located.

One of the reasons that changes little is that programmers don’t care much about this. They can do this consciously, prioritizing the right things, or just because they can’t do better.

Tutorial.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.