Language Tags
the next generation
Internationalization and Unicode Conference #32
1
Presenters
Addison PhillipsLab126
Mark DavisGoogle
2
Languages, Language Tags, and Locales (oh my!)
Identifying language (and locale)—the challenge
ISO 639 IETF BCP 47
– RFC 4646, RFC 4647– RFC 4646bis
Challenges for users
3
Human Language as Metadata
Some data is just data, but some data is human-readable text.
Text processing depends on language:– spelling, stemming, tokenization, word/line/sentence
boundaries, thesauri, terminology, morphological analysis, font and stylistic traditions, collation.
IT systems depend on language negotiation:– localization, message selection, user interface, presentation,
number/date/time/etc. formatting, list presentation
4
Human Language
"Ole Missus, de house of plum` jam full o` people, en dey`s jes a-spi`lin` to see de gen`lemen!"
(Mark Twain, Puddinhead Wilson)
IN this book a number of dialects are used, to wit: the Missouri negro dialect; the extremest form of the backwoods Southwestern dialect; the ordinary "Pike County" dialect; and four modified varieties of this last. The shadings have not been done in a haphazard fashion, or by guesswork; but painstakingly, and with the trustworthy guidance and support of personal familiarity with these several forms of speech. I make this explanation for the reason that without it many readers would suppose that all these characters were trying to talk alike and not succeeding.
5
Identifying Languages
Languages don’t form nice hierarchies– “splitters” vs “lumpers”– dialects, subdialects, regional and stylistic differences,
patois Differing communities with different needs
– terminology, librarians, computer systems, translators, etc.
6
In the Beginning (ca. 1980 CE)
Received Wisdom from the Dark Ages Locales:
– japanese, french, german, C– ENU, FRA, JPN– ja_JP.PCK– AMERICAN_AMERICA.WE8ISO8859P1
Languages…… looked a lot like locales (and vice versa)
7
ISO 639
Defines language identifier codes Multiple parts:
– ISO 639-1 (alpha2 codes676) (136 codes)– ISO 639-2 (alpha3 codes17576) (about 500)– ISO 639-3 (alpha3 codes) (about 7000)– ISO 639-4 (principles for encoding)– ISO 639-5 (language families)– ISO 639-6 (alpha4 codes) (under development)
8
Impact of ISO 639-3
ISO 639-2 and 639-3 share a codespace– all 639-2 codes are also 639-3 codes– Macrolanguages
9
Human Language
"Ole Missus, de house of plum` jam full o` people, en dey`s jes a-spi`lin` to see de gen`lemen!"
(Mark Twain, Puddinhead Wilson)
en
10
Parallel Efforts
ISO 639– ISO 639-1 (early 1980s)
– ISO 639-2 (alpha3)
– ISO 639-3 (2007)
IETF BCP 47– RFC 1766 (1995)
– RFC 3066 (2001)
– RFC 4646 (2006)– RFC 4646bis (2008)
11
BCP 47
Internet Engineering Task Force (IETF) “Best Current Practice” (BCP)
Enable presentation, selection, and negotiation of content in protocols and formats
– Widely used! XML, HTML, RSS, MIME, SOAP, SMTP, LDAP, CSS, XSL, CCXML, Java, C#, ASP, perl, Apache, IE, Mozilla……….
12
Adds Granularity
Need to identify language on varying levels of mutual intelligibility and granularity
"Ole Missus, de house of plum` jam full o` people, en dey`s jes a-spi`lin` to see de gen`lemen!"
(Mark Twain, Puddinhead Wilson)en
en-US
13
BCP 47 (Historic) Basic Structure
Alphanumeric (ASCII only) subtags Up to eight characters long Separated by hyphens Case not important (i.e. zh = ZH = zH = Zh)
1*8alphanum * [ “-” 1*8 alphanum ]
14
RFC 1766
zh-TW
ISO
63
9-1
(alp
ha2
)
ISO
31
66 (a
lpha2)
i-klingoni-klingonR
egiste
red
valu
e
15
RFC 3066
sco-GB
ISO
63
9-2
(alp
ha 3
codes)
But use…
enengg-GB-GBalpha 2 codes when they exist
X
16
What’s a Locale
– “a concept or identifier used by programmers to represent a particular collection of cultural, regional, or linguistic preferences.”
java.util.Locale.Net CultureLANG (setlocale in C, C++)NLS_LANG in Oracle… and so on…
17
Locales? Huh?
Theatre Center News: The date of the last version of this document was 2003 年 3 月 20. A copy can be obtained for $50,0 or 1.234,57 грн. We would like to acknowledge contributions by the following authors (in alphabetical order): Alaa Ghoneim, Behdad Esfahbod, Ahmed Talaat, Eric Mader, Asmus Freytag, Avery Bishop, and Doug Felt.
18
Locales and Languages
locale language + [other stuff]≊ Language needs to specify written form
U+224A (“≊”) = ALMOST EQUAL OR EQUAL TO
19
Locale Identifiers
Different ideas:– “Accept-Locale” vs. Accept-Language– URIs/URNs, etc.– CLDR/LDML
And Requirements:– Operating environments and harmonization– App Servers– Web Services
New Solution? Cost of Adoption:– UTF-8 to the browser: 8 long years
20
Locales and Language Tags meet
We really need locale identifiers.
Language tags are being (ab)used as locale identifiers
anyway…
Not going to need a big new
thing…
… we can do this really fast…
Yeah, we’ll write an RFC
IUC23, March 2003
21
Problems with BCP 47 (circa RFC 3066)
Script Variation:– zh-Hant/zh-Hans– (sr-Cyrl/sr-Latn, az-Arab/az-Latn/az-Cyrl, etc.)
Obsolesce of registrations:– art-lojban (now jbo), i-klingon (now tlh)
Instability in underlying standards:– sr-CS (CS used to be Czechoslovakia and now it’s not
Serbia and Montenegro) Lack of a single authoritative, stable source22
And More Problems
Little support for registered values in software Reassignment of values by ISO 3166 Lack of consistent tag formation (Chinese dialects?) Standards not readily available, bad references Bad implementation assumptions
– the rules: 1*8 alphanum *[ “-” 1*8 alphanum]example “abcd1234-5678efgh-boont”
– badly interpreted as: 2*3 ALPHA [ “-” 2ALPHA ]example: only stuff like “en-US” or “frr-CH”
Many registrations to cover small variations– 8 German registrations to cover two variations
23
LTRU and RFC 4646
Defines a generative syntax – machine readable– future proof, extensible
Defines a single source (IANA Language Subtag Registry)– Stable subtags, no conflicts– Machine readable
Defines when to use subtags– (sometimes)
24
Anatomy of a Language Tag
sl-Latn-IT-rozaj-1994-r-foovia-x-mine
ISO
63
9-1
/2 (a
lpha2/3
)
ISO
15
924 scrip
t codes
(alp
ha 4
)
ISO
31
66 (a
lpha2) o
r UN
M
49 R
egiste
red v
aria
nts
Priv
ate
Use
Exte
nsio
ns (n
one a
t pre
sent)
25
More Examples
fr, de, nl, en, ja fr-FR, fr-CA, de-DE, de-CH… es-419 (Spanish for Americas) en-US (English for USA) de-CH-1996 (Old tags are all valid) sl-rozaj-1994 (Multiple variants) zh-t-wadegile (Extensions)
26
Solves the Script problem
zh-Hant (!= zh-TW) zh-Hans (!= zh-CN)
Azerbaijani (az)– Arab, Cyrl, Latn
Serbian (sr)– Cyrl, Latn
Yiddish (yi)– Hebr, Latn
Mongolian (mn)– Cyrl, Latn, Hani
Belarussian (be)– Cyrl, Latn
Etc.
27
Benefits
Subtag registry in one place: one source, machine-readable
Subtags identified by length/content Extensible Compatible with RFC 3066 tags Stable: subtags are forever
28
Tag Choice
“Tag Content Wisely”– use the shortest tag reasonable– use as many subtags as necessary to disambiguate– don’t invent things; use the registry– map deprecated values to modern equivalents
Suppress-Script– avoid scripts when they add no additional information
(Suppress-Script in the registry indicates this for some languages in some cases.)
29
Specialized Subtags
zxx (non-linguistic, not applicable)
und (undetermined)
mis (uncoded)
mul (multiple)
Zxxx (not written) Collection codes
30
Unicode Language Identifiers (CLDR)
Adds some region codes:
– ZZ– QU– etc.
Provides for canonicalization
Restricts syntax:– no grandfathered
codes– no extlang
31
Problems
Matching– Does “en-US” match “en-Latn-US”?
Tag Choices– Users have more to choose from.
Implementations– More to do, more to think about– (easier to parse, process, support the good stuff)
32
Tag Matching (RFC 4647)
Uses “Language Ranges” in a “Language Priority List” to select sets of content according to the language tag
Three Schemes– Basic Filtering– Extended Filtering– Lookup
– See also: “Unicode in Google” talk for “distance matching” (later today)
33
Tags are not Tokens!
Many technologies would like language tags (attributes, etc.) to be atomic—but language tags have structure
<span class=“foo” xml:lang=“en-US” />
foo(lang:en) {color: red;
}
Accept-Language=zh;q=1.0;de-DE;q=0.8
34
Filtering
Ranges specify the least specific item – “en” matches “en”, “en-US”, “en-Brai”, “en-boont”
Basic matching uses plain prefixes– “en-US” matches “en-US” or “en-US-boont” but not
“en-Latn-US”
Extended matching can match “inside bits”– “en-*-US”
35
Lookup
Range specifies the most specific tag in a match. Returns exactly one item.
– “en-US” might return either “en” or “en-US” but not “en-US-boont”
Mirrors the locale fallback mechanism and many language negotiation schemes.
36
Lookup and Language Negotiation
Resources “fall back” to find the best match
Global Binary
Resources
zh-Hans-SG (Chinese, Simplified script, Singapore)
zh-Hans (Chinese, Simplified script)
zh (Chinese)
(root)
Fallin
g b
ack
See also: “Unicode in Google” talk (later today)37
What Do I Do (Content Author)?
Not much.– Existing tags are all still valid: tagging is mostly
unchanged.– Resist temptation to (ab)use the private use subtags.
Unless your language has script variations:– Tag content with the appropriate script subtag(s)
Script subtags only apply to a small number of languages: “zh”, “sr”, “uz”, “az”, “mn”, and a very small number of others.
38
What Do I Do (Programmer)?
Check code for compliance with RFC 4646– Decide on well-formed or validating– Implement suppress-script– Change to using the registry– Bother infrastructure folks (Java, MS, Mozilla, etc) to
implement the standard
39
I need a new subtag…
Register new subtags with [email protected]
– only primary language or variant subtags– read RFC 4646 for instructions– two-week review period with expert approval
40
LTRU Milestone Dates
RFC 4646 – Registry went live in December 2005
RFC 4647 (Anticipated) RFC 4646bis
– This includes ISO 639-3 support, extended language subtags, and possibly ISO 639-6
41
RFC 4646bis (Internet-Draft)
Currently taking shape– Adds about 7000 additional primary language subtags
from ISO 639-3– Extended language subtags for Chinese and other
languages being debated… and some cleanup work on processes and procedures
42
Macrolanguages and Extlang: The Big Debate
zh-Hant-HK Chinese, Traditional Script, Hong Kong SAR
yue-Hant-HK Cantonese, Traditional Script, Hong Kong SAR
zh-yue-Hant-HKChinese, Cantonese, Traditional Script, Hong Kong SAR
extlang
or do we do………..
43
Current Solution
yue-Hant-HK
zh-yue-Hant-HKPermitted, but
Deprecated in favor of “no extlang”
form
44
Things to Do (languages)
Get involved in LTRU Get involved in W3C Internationalization Activity Get involved with Unicode and CLDR Write implementations Work on adoption of BCP 47: understand the
impact
45
Things to Read
Tag and Registry RFChttp://www.ietf.org/rfc/rfc4646.txt
Matching RFChttp://www.ietf.org/rfc/rfc4647.txt
4646bis Drafthttp://www.ietf.org/internet-drafts/draft-ltru-4646bis-17.txt
Referenceshttp://www.langtag.nethttp://www.inter-locale.com
LTRU Mailing Listhttps://www1.ietf.org/mailman/listinfo/ltru
46
Ideas and Questions
47