Why Open Graph tags use en_GB instead of en-GB
HTML esoterica – en-GB vs. en_GB

Terence Eden digs into an HTML quirk: the lang attribute follows BCP 47 with hyphens, while Open Graph's og:locale uses underscores like en_GB. The reason is that a language is not a locale—a locale also covers date formats, decimal marks, and currency. The underscore traces back to POSIX's ISO/IEC 15897, and since Facebook's OGP development is effectively dead, Eden suggests replacing og:locale with lang.
A language is not the same as a locale, and an underscore is not the same as a hyphen, and a Facebook recommendation is not the same as a living standard.
- SyzygyRhythm
The page doesn't seem to quite spell out the answer, which is that lang and locale have nothing to do with each other. It's basically coincidence that they look even similar. The locale came from basically an ad-hoc system from X/Open in the late 80s, while lang comes from RFC 5646 in 2009. The two become more obviously different if you need to specify anything complicated, like sr_RS.UTF-8@latin or zh-cmn-Hans-CN.
- numpad0
> A language only tells you about the language. A locale, by contrast, tells you about the user's preferences.
I think it's more like, it just so happens that choosing language resources based on this pair of parameters is useful, because neither of these are particularly good boundaries.
There are people like Spanish speakers in the US, German speakers in Switzerland, Portuguese speakers in Brazil, things like that. So either of languages or flags alone is not enough, but combinations of both works 99% of the time. So that gets used.
- trebligdivad
I wish some Locale would treat _ and - as equivalent for searches and case-insensitive comparisons, so we could all stop worrying about which is the right one to use in many different places.
- nubinetwork
> For example, this is valid HTML ...(snip)... That says the site's name is in French but the description is in English. That will parse perfectly.
Is this why I get websites that triggers google translate despite already being in my language, or why it only translates parts of the page?
- hibbelig
I don’t unterstand this. In order to write correct text i have to know some conventions, such as number formatting. So just language and locale are kind of hard to separate. Why dies the author say that the locale doesn’t matter for strings in OGP metadata?