Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Builds well-formed BCP-47 locale identifiers (language-Script-REGION, e.g. zh-Hant-HK, sr-Latn, pt-BR) and resolves a missing translation through a correct fallback chain by trimming subtags right-to-left (zh-Hant-HK → zh-Hant → zh → the default), never crossing a script boundary, never sideways-matching a different region, and never showing the raw key. Use when picking the locale code for a resource file / language switcher, or deciding which available translation to serve a user whose exact locale is missing. Do NOT use for adapting dates/numbers/currency to a locale's display conventions, for plural-arm selection, or for translating prose.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 441% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 457% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 468% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 450% | 0% |
| case-12 | ✓→✓ | = Same ✓ | 478% | 0% |
Two jobs that framework tutorials assume you already know: name a locale correctly, and decide which translation to serve when the exact one is missing. The base model knows the form of a language tag but does not default to the right one — it invents subtags (zh-Simplified, en-UK), guesses the script/region axis, and when a translation is missing it grabs any file that shares the language — which can hand a Hong Kong reader Simplified text or show a raw string key. This skill forces well-formed tags and a deterministic fallback.
A tag is language, then an optional Script, then an optional REGION, in that order, joined by hyphens. Casing is conventional (case-insensitive to parsers, but write it the canonical way):
| Subtag | Length / form | Case | Examples | |---|---|---|---| | language | 2–3 letters | lower | zh, sr, pt, en, fr | | Script | exactly 4 letters | Title | Hans, Hant, Latn, Cyrl | | REGION | 2 letters, or 3 digits (UN M.49) | UPPER | CN, HK, BR, GB, 419 |
So zh-Hant-HK = Chinese, Traditional script, Hong Kong region.
Script and region are different axes — do not confuse them. zh-Hans says which writing system (Simplified Han); zh-CN says which country (mainland China, Simplified by convention). Pick the script subtag when the writing system is the thing that differs; pick the region when a country's conventions differ. When both matter, use both (zh-Hant-HK).
zh-Hans (Simplified) vs zh-Hant (Traditional). Regions: zh-CN, zh-SGare Simplified-writing; zh-TW, zh-HK, zh-MO are Traditional-writing.
sr-Latn (Latin) vs sr-Cyrl (Cyrillic). Bare sr is ambiguous — mark thescript.
pt-BR (Brazil) vs pt-PT (Portugal).es-419 — the region is the M.49 numeric code 419, not a country.en-GB, not en-UK. US is en-US.Emit only real registered subtags. Wrong, and what it should be:
zh-Simplified, zh-simplified, zh-CHS → zh-Hanszh-Traditional, zh-CHT → zh-Hantpt-Brazil → pt-BR · en-UK → en-GB · es-LatinAmerica → es-419zh-HantHK); separate them: zh-Hant-HK.Given a requested locale and the set of locales you actually have, resolve by prefix truncation (the RFC 4647 "lookup" rule):
zh-Hant-HK → zh-Hant → zh.(usually en, or whatever your app declares).
Three rules that make this correct rather than naive:
the language. zh-Hant and zh-Hans share the language zh but are mutually unreadable — Traditional and Simplified. Truncation never turns zh-Hant-* into zh-Hans, because zh-Hans is not a prefix of zh-Hant-HK. Do not add sideways matching that would.
pt-BR with only pt-PT and en availableresolves to en, not pt-PT — pt-PT is not in the chain pt-BR → pt → default.
string in the default language, never the literal message key or the tag zh-Hant-HK.
Requested zh-Hant-HK; available {zh-Hant, zh-Hans, en}:
zh-Hant-HK → miss
zh-Hant → HIT ✅ serve thisNever zh-Hans (would be Simplified text for a Traditional reader). If instead only {zh-Hans, en} were available, the chain zh-Hant-HK → zh-Hant → zh all miss, so serve en — not zh-Hans.
Use when choosing the identifier for a resource file, translation column, or language switcher, or when deciding which existing translation to show a user whose exact locale you don't have.
Do NOT use for: formatting dates/numbers/currency to a locale (that is a formatting skill), plural category selection, or translating the actual prose.
For the extended language → script/region catalog, region-code gotchas, and the full lookup steps, see references/bcp47-catalog.md.
Other measured skills in the registry, with their headline benchmark lift.