hn.today

HTML esoterica – en-GB vs. en_GB

htmhell.dev20 points1 comments
Screenshot of HTML esoterica – en-GB vs. en_GB

The discussion investigates why HTML uses two similar-looking conventions: the `lang` attribute takes a BCP 47 language tag such as `en-GB`, while Open Graph’s `og:locale` uses an underscore form such as `en_GB`. The distinction is partly semantic. `lang` identifies the language of particular content, and can be applied to individual metadata elements - for example, a French site name and an English description. Open Graph defines `og:locale` as the locale of its tags, not necessarily the language of the page, and specifies values in a language-territory format.

The explanation traces the underscore convention to POSIX locale standards, which adopted it, while Facebook’s older locale documentation and SDK examples help explain how it entered Open Graph. A locale can encode conventions beyond language, including date, number, and currency presentation. But much Open Graph data gains little from that extra information: dates use ISO 8601, and payment currency is specified with an ISO currency code. Locale may matter most for displaying numbers with the appropriate decimal and thousands separators. Because Open Graph is poorly maintained and `lang` can express the language of each metadata value directly, the author argues that `og:locale` should be retired in favor of `lang`. The broader lesson is that language tags and locales serve different purposes, and Open Graph’s legacy syntax is not a living web standard.

Read on htmhell.dev1 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Web

Are EU Kidding Me?

Are EU Kidding Me?

A legal scholar argues that the EU’s proposed Kids Act is poorly drafted, with conflicting rules and broad language that could sweep in unrelated services and restrict products such as voice assistants. He urges the European Commission to withdraw the proposal and rewrite it with clearer, workable requirements. (michae.lv)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.