Prompt
What should I use for regional locale variants and fallback rules
Latest observation
Nov 20, 2026
OpenAI APIWeb search: off
A good default is:
- Use the IETF BCP 47 language tag format for locale identifiers, like:
enen-USpt-BRzh-Hant-TW
Recommended fallback rules
Use a progressive fallback from most specific to least specific:
-
Exact match
en-GB→en-GB
-
Remove region/script variants step by step
en-GB→enzh-Hant-TW→zh-Hant→zh
-
Default locale
- If nothing matches, fall back to a configured default, like
en
- If nothing matches, fall back to a configured default, like
Example fallback chain
If the requested locale is pt-BR and only these are available:
pt-BRpten
Then the lookup order should be:
pt-BRpten
Best practices
- Prefer language-only locale as the base fallback unless you truly need region-specific differences.
- Keep a single canonical form for stored locale tags, usually lowercase language and uppercase region:
en-US,fr-CA,zh-Hans-CN
- Use a library if possible to parse/compare locales correctly, especially for:
- script subtags
- grandfathered tags
- aliases/normalized tags
If you want a simple rule set
Use this:
- Try exact locale
- Then try language + script
- Then try language only
- Then try configured default
If you want, I can also give you:
- a code example for locale fallback
- a recommended database schema
- or a comparison of ICU vs BCP 47 handling