ptr727.LanguageTags
1.0.14
See the version list below for details.
dotnet add package ptr727.LanguageTags --version 1.0.14
NuGet\Install-Package ptr727.LanguageTags -Version 1.0.14
<PackageReference Include="ptr727.LanguageTags" Version="1.0.14" />
<PackageVersion Include="ptr727.LanguageTags" Version="1.0.14" />
<PackageReference Include="ptr727.LanguageTags" />
paket add ptr727.LanguageTags --version 1.0.14
#r "nuget: ptr727.LanguageTags, 1.0.14"
#:package ptr727.LanguageTags@1.0.14
#addin nuget:?package=ptr727.LanguageTags&version=1.0.14
#tool nuget:?package=ptr727.LanguageTags&version=1.0.14
LanguageTags
C# .NET library for ISO 639-2, ISO 639-3, RFC 5646 / BCP 47 language tags.
Build Status
Code and Pipeline is on GitHub
NuGet Package
Packages published on NuGet
References
- Wikipedia : Codes for constructed languages
- Wikipedia : IETF language tag
- W3C : Choosing a Language Tag
- W3C : Language tags in HTML and XML
- W3C : BCP47 language subtag lookup
- IANA : Language Subtags, Tag Extensions, and Tags
- RFC : BCP47
- RFC : 4647 : Matching of Language Tags
- RFC : 5646 : Tags for Identifying Languages
- Unicode Consortium : Unicode CLDR Project
- Library of Congress : ISO 639-2 Language Coding Agency
- SIL International : ISO 639-3 Language Coding Agency
Build Process
The build process downloads the latest language tag data files, converts them into JSON files for easy consumption, and generates C# classes with all the tags for direct use in code.
- ISO 639-2: Source, Data, JSON, Code
- ISO 639-3: Source, Data, JSON, Code
- RFC 5646: Source, Data, JSON, Code
The data files are updated on a weekly bases using a scheduled actions job.
Usage
Tag Lookup
Iso6392 iso6392 = Iso6392.Create();
Iso6393 iso6393 = Iso6393.LoadData("Iso6393");
Rfc5646 rfc5646 = Rfc5646.LoadJson("Rfc5646.json");
public Record Find(string languageTag, bool includeDescription);
Iso6392.Record record = iso6392.Find("afr", false)
// record.Part2B = afr
// record.RefName = Afrikaans
record = iso6392.Find("zulu", true)
// record.Part2B = zul
// record.RefName = Zulu
Iso6393.Record record = iso6393.Find("zh", false)
// record.Id = zho
// record.Part1 = zh
// record.RefName = Chinese
record = iso6392.Find("yue chinese", true)
// record.Id = yue
// record.RefName = Yue Chinese
Rfc5646.Record record = rfc5646.Find("de", false)
// record.SubTag = de
// record.Description = German
record = iso6392.Find("zh-cmn-Hant", false)
// record.Tag = zh-cmn-Hant
// record.Description = Mandarin Chinese (Traditional)
record = iso6392.Find("Inuktitut in Canadian", true)
// record.Tag = iu-Cans
// record.Description = Inuktitut in Canadian Aboriginal Syllabic script
Tag Conversion
LanguageLookup languageLookup = new();
languageLookup.GetIetfFromIso("afr"); // af
languageLookup.GetIetfFromIso("zho"); // zh
LanguageLookup languageLookup = new();
languageLookup.GetIsoFromIetf("af"); // afr
languageLookup.GetIsoFromIetf("zh-cmn-Hant"); // chi
languageLookup.GetIsoFromIetf("cmn-Hant"); // chi
Tag Matching
RFC 5646 / BCP 47 language tags are in the form of language-extlang-script-region-variant-extension-privateuse
, and matching happens left to right.
E.g. pt
will match pt
Portuguese, or pt-BR
Brazilian Portuguese, or pt-PT
European Portuguese.
E.g. pt-BR
will only match only pt-BR
Brazilian Portuguese.
E.g. zh
will match zh
Chinese, or zh-Hans
simplified Chinese, or zh-Hant
for traditional Chinese, and other variants.
E.g. zh-Hans
will only match zh-Hans
simplified Chinese.
LanguageLookup languageLookup = new();
languageLookup.IsMatch("en", "en-US"); // true
languageLookup.IsMatch("zh", "zh-cmn-Hant"); // true
languageLookup.IsMatch("sr-Latn", "sr-Latn-RS"); // true
languageLookup.IsMatch("zha", "zh-Hans"); // false
languageLookup.IsMatch("zh-Hant", "zh-Hans"); // false
3rd Party Tools
- AwesomeAssertions
- Bring Your Own Badge
- CSharpier
- Create Pull Request
- GH Release
- Git Auto Commit
- GitHub Actions
- GitHub Dependabot
- Husky.Net
- Nerdbank.GitVersioning
- Serilog
- xUnit.Net
Other Language Tag Libraries
- github.com/DanSmith/languagetags-sharp
- github.com/jkporter/bcp47
- github.com/mattcg/language-subtag-registry
- github.com/rspeer/langcodes
License
Licensed under the MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.46 | 91 | 8/14/2025 |
1.0.45-g3185f6be67 | 89 | 8/14/2025 |
1.0.44 | 91 | 8/11/2025 |
1.0.43-gcfcbaf6aaa | 86 | 8/11/2025 |
1.0.42-gb52ba3d4ff | 85 | 8/11/2025 |
1.0.40 | 249 | 7/26/2025 |
1.0.39-g88d004516d | 244 | 7/26/2025 |
1.0.38-gf999e9bb85 | 248 | 7/26/2025 |
1.0.37-g9ecfb29655 | 19 | 7/19/2025 |
1.0.35 | 116 | 7/17/2025 |
1.0.35-g93861ef687 | 111 | 7/17/2025 |
1.0.34-gd7ad864d88 | 109 | 7/17/2025 |
1.0.33-g56e9a89989 | 105 | 7/17/2025 |
1.0.32 | 110 | 7/17/2025 |
1.0.32-g8305691a24 | 106 | 7/17/2025 |
1.0.31-gc13a26c4f6 | 106 | 7/17/2025 |
1.0.29-gd8e72ab853 | 109 | 7/17/2025 |
1.0.26 | 175 | 7/15/2025 |
1.0.24 | 259 | 7/11/2025 |
1.0.23-gbb8ffe5bb2 | 127 | 7/11/2025 |
1.0.22-ga1ac78f1df | 130 | 7/11/2025 |
1.0.21 | 158 | 6/30/2025 |
1.0.21-g9302ac7f90 | 131 | 7/10/2025 |
1.0.20-gd3feb5712d | 132 | 6/30/2025 |
1.0.19 | 171 | 6/23/2025 |
1.0.19-gde8fbe4b5f | 130 | 6/30/2025 |
1.0.18-g54f8783ae2 | 134 | 6/23/2025 |
1.0.17-g7df622bb81 | 131 | 6/23/2025 |
1.0.16-g81e118866b | 130 | 6/16/2025 |
1.0.15-g53ab3f4809 | 122 | 6/15/2025 |
1.0.14 | 155 | 6/15/2025 |
1.0.13 | 129 | 6/15/2025 |
1.0.13-g17063ec750 | 130 | 6/15/2025 |
1.0.12-g52f15572a7 | 128 | 6/15/2025 |
1.0.11-g70c3a3028c | 124 | 6/15/2025 |
1.0.10-g22cc5cba88 | 139 | 6/14/2025 |
1.0.9-g7483a8ee5e | 138 | 6/14/2025 |
1.0.8-gcb3125b986 | 139 | 6/14/2025 |
1.0.7-g3d65ad190a | 113 | 6/14/2025 |
1.0.5-g78c1403494 | 116 | 6/14/2025 |
1.0.4-g5f05a80e82 | 144 | 6/14/2025 |
1.0.3-g7b075aa3eb | 149 | 6/14/2025 |
1.0.2 | 145 | 6/14/2025 |
1.0.1 | 120 | 6/14/2025 |
1.0.0-pre | 144 | 6/14/2025 |