Language Tag Parser
Canonicalize an ECMA-402 Unicode locale identifier and extract its language, script, region, and base name.
Description
A Unicode locale identifier identifies language and optional script, region and extensions.
When to use Language Tag Parser
Use this tool to canonicalize an ECMA-402 Unicode locale identifier and extract its language, script, region, and base name.
Enter the locale identifier to canonicalize and inspect using the runtime internationalization API.
How to use Language Tag Parser and understand its results
- Enter the locale identifier to canonicalize and inspect using the runtime internationalization API.
- Enter tag using the field table and calculation rules, then run the tool.
- Read canonical, language, script, region, baseName. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| tag | Unicode locale identifier accepted by Intl.Locale. | string; maximum length: 1000000 | Required |
Enter a structurally valid tag accepted by the runtime. Return canonical tag, language, optional script/region as empty strings if absent, and baseName without extensions.
locale=new Intl.Locale(tag) Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| canonical | Canonical locale identifier. | string; maximum length: 1000000 |
| language | Language subtag. | string; maximum length: 1000000 |
| script | Script subtag, empty when absent. | string; maximum length: 1000000 |
| region | Region subtag, empty when absent. | string; maximum length: 1000000 |
| baseName | Locale identifier without extensions. | string; maximum length: 1000000 |
{
"input": {
"tag": "zh-hant-tw-u-nu-hanidec"
},
"output": {
"canonical": "zh-Hant-TW-u-nu-hanidec",
"language": "zh",
"script": "Hant",
"region": "TW",
"baseName": "zh-Hant-TW"
}
} Limitations and assumptions
No trimming, language detection or likely-subtag maximization is performed. Acceptance/canonical aliases follow runtime ECMA-402 data, not every possible BCP 47 form.
Numeric inputs, where present, must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use Greek Diacritic Analyzer: Count Greek accent and breathing marks after canonical Unicode decomposition. For a complementary task, use CSS Media Query Extractor: Extract lexical @media query preludes from CSS while ignoring quoted strings and comments, without evaluating conditions.
Further background: ECMA-402: Intl.Locale.
References
-
Language Tag Parser — tool.io
-
ECMA-402: Intl.Locale — Ecma International
Similar or alternative tools
- Greek Diacritic Analyzer
Count Greek accent and breathing marks after canonical Unicode decomposition.
- CSS Media Query Extractor
Extract lexical @media query preludes from CSS while ignoring quoted strings and comments, without evaluating conditions.