Repository navigation
IANA Registry
Enbrea.Bcp47.Iana contains a bundled snapshot of the IANA Language Subtag Registry.
The registry is compiled into the package as generated compact lookup data. No network access or runtime CSV parsing is required. The public access API is IanaLanguageSubtagRegistry.
The source registry's file date is available through FileDate:
DateOnly date = IanaLanguageSubtagRegistry.FileDate;This identifies the registry snapshot from which the bundled lookup data was generated.
IanaLanguageSubtagType defines the supported registry record types:
Language
Extlang
Script
Region
Variant
Grandfathered
Redundant
These correspond to either registered subtags or complete registered tags.
Use ContainsLanguage():
bool registered = IanaLanguageSubtagRegistry.ContainsLanguage("de");The method also recognizes the RFC/IANA reserved private-use language range qaa through qtz:
IanaLanguageSubtagRegistry.ContainsLanguage("qaa"); // trueRegistry range expressions themselves are storage notation and are not treated as actual subtags.
bool registered = IanaLanguageSubtagRegistry.ContainsScript("Latn");The reserved private-use script range Qaaa through Qabx is also accepted for use as a script subtag.
bool registered = IanaLanguageSubtagRegistry.ContainsRegion("DE");The reserved region ranges QM through QZ and XA through XZ are also recognized.
Dedicated methods are available for the other registry types:
IanaLanguageSubtagRegistry.ContainsExtlang("cmn");
IanaLanguageSubtagRegistry.ContainsVariant("1901");
IanaLanguageSubtagRegistry.ContainsGrandfatheredTag("i-klingon");
IanaLanguageSubtagRegistry.ContainsRedundantTag("zh-cmn");A generic API is also available:
bool result = IanaLanguageSubtagRegistry.Contains(
IanaLanguageSubtagType.Language,
"de");Use IsDeprecated() with a registry type:
bool deprecated = IanaLanguageSubtagRegistry.IsDeprecated(
IanaLanguageSubtagType.Language,
"iw");A deprecated entry remains a registry entry. Deprecation therefore does not imply that Contains() returns false.
Some deprecated or legacy records define a Preferred-Value.
Use TryGetPreferredValue():
if (IanaLanguageSubtagRegistry.TryGetPreferredValue(
IanaLanguageSubtagType.Language,
"iw",
out var preferred))
{
Console.WriteLine(preferred);
}The core package does not automatically apply these mappings during normalization. Core normalization is registry-independent. See Normalization and Equality.
Variants can define one or more registry prefixes.
Use GetVariantPrefixes():
var prefixes = IanaLanguageSubtagRegistry.GetVariantPrefixes("rozaj");
foreach (var prefix in prefixes)
{
Console.WriteLine(prefix);
}If the variant has no registered prefixes, an empty list is returned.
The prefix associated with an extlang can be queried with:
if (IanaLanguageSubtagRegistry.TryGetExtlangPrefix(
"cmn",
out var prefix))
{
Console.WriteLine(prefix);
}The validator exposes registry membership independently of prefix guidance. See IANA Validation.
Languages can define a Suppress-Script value:
if (IanaLanguageSubtagRegistry.TryGetLanguageSuppressScript(
"de",
out var script))
{
Console.WriteLine(script);
}Extlangs can be queried separately:
IanaLanguageSubtagRegistry.TryGetExtlangSuppressScript(
"cmn",
out var script);Suppress-Script is metadata. The core normalizer does not remove scripts based on this field.
Language and extlang records can expose macrolanguage relationships:
IanaLanguageSubtagRegistry.TryGetLanguageMacrolanguage(
language,
out var macrolanguage);For extlangs:
IanaLanguageSubtagRegistry.TryGetExtlangMacrolanguage(
extlang,
out var macrolanguage);Most IANA registry entries describe individual subtags. Two registry types describe complete tags instead:
- grandfathered tags
- redundant tags
These are queried with:
IanaLanguageSubtagRegistry.ContainsGrandfatheredTag(value);
IanaLanguageSubtagRegistry.ContainsRedundantTag(value);Their deprecation and preferred-value metadata can be queried through the same generic APIs by using IanaLanguageSubtagType.Grandfathered or IanaLanguageSubtagType.Redundant.
The package does not download registry data at runtime. Its generated lookup tables represent a specific registry snapshot.
Applications that need to know the snapshot age can inspect:
IanaLanguageSubtagRegistry.FileDateUpdating the NuGet package to a release containing a newer generated snapshot updates the registry data used by the application.