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

6

I was not able to see any differences between the two values in the tests. Anybody know? To help: The first two characters of the value define the Language Code Reference (ISO 639-1) and the last two characters, after the tab, identify the Country Code Reference (ISO 3166-1). But when we omit the Country Code, what actually changes? I do not see anything different in IE and Chrome browsers and developers usually do not report the country.

    
asked by anonymous 20.03.2016 / 21:27

2 answers

9

I will summarize well, pt indicates Portuguese, regardless of country / region as:

Source: Which countries and regions speak Portuguese?

  • Brazil (Brazil)
  • Portugal (Portugal)
  • São Tomé and Príncipe (São Tomé and Príncipe)
  • Angola (Angola)
  • Mozambique (Mozambique)
  • Cape Verde (Cape Verde)
  • East Timor
  • Guinea-Bissau (Guinea-Bissau)
  • Equatorial Guinea (Equatorial Guinea)
  • Macau (Macau) †

When we use pt-BR we indicate Portuguese of Brazil, as well as pt-PT indicates Portuguese of Portugal.

Portuguese as well as English have variations in different countries, indicating pt-BR , pt-PT , pt , en , en-US , en-GB do not interfere with HTML , are only values to tell you what language you are in, for example some browsers have page language detection and they can pass to some plugin, or an add-on can use the attribute directly. / p>

Placing the URL of the page that uses this attribute on link will detect that that <div lang="pt-BR"></div> uses Brazilian Portuguese (although google does not differ much either).

Others that can usually use this attribute are search engines like Google, Bing, Yahoo, Baidu. Search engines use these attributes to deliver pages of the regional and language preference of a person they are searching for.

Now speaking only HTML, the lang attribute regardless of its value, pt or pt-BR does not change at all, the idea of using it is normalize and indicate the types of data for those who have interest, if there is no such attribute plugins, google translator or search engines have more difficulty detecting the language and region of the page.

    
20.03.2016 / 21:45
4

When you speak only the language, that content will be used in specific tools configured for that language. When you enter the language and the regional dialect the content will only be used in the tool configured for that country. Unless you do not have this configuration, but have the language, then it takes advantage of what you have available information.

The attribute lang is one more 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 localized.

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

Tutorial .

    
20.03.2016 / 21:52