logoalt Hacker News

SyzygyRhythm • today at 7:34 AM • 4 replies • view on HN

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.


Replies

dasyatidprime • today at 9:33 AM

This is basically correct. It's worth an addendum though that IETF language tags are in turn based substantially on ISO 639 language codes and ISO 3166 country codes, and while AFAIK POSIX doesn't mandate the use of these vocabularies, it's de facto common practice to use them for the language and territory parts of POSIX locales as well. So there's some indirect, distant shared background. Beyond that, the two strings contain intersecting but differing sets of information because they were made for different purposes: affecting the ambient behavior of a user environment and its applications versus describing the language of content on the Internet. For instance, a POSIX locale can imply a default character set for text I/O, which is out of scope for an IETF language tag.

account42 • today at 9:48 AM

The situation is much more blurry than you make it out to be since the locale is the primary means to specify a language on POSIX systems. Sure, a locale string can encompass much more than just the language but the xx_XX part is still primarily about language.

fanf2 • today at 12:56 PM

IETF MIME language tags go back to RFC 1766 (1995)

https://www.rfc-editor.org/info/rfc1766/

JdeBP • today at 1:47 PM

Don't sell the RFCs short. RFC 1766 is an ad-hoc system too, from the 1990s. (-: