NLanguageTag 4.0.0
dotnet add package NLanguageTag --version 4.0.0
NuGet\Install-Package NLanguageTag -Version 4.0.0
<PackageReference Include="NLanguageTag" Version="4.0.0" />
paket add NLanguageTag --version 4.0.0
#r "nuget: NLanguageTag, 4.0.0"
// Install NLanguageTag as a Cake Addin #addin nuget:?package=NLanguageTag&version=4.0.0 // Install NLanguageTag as a Cake Tool #tool nuget:?package=NLanguageTag&version=4.0.0
LanguageTag
Language tags are used to help identify languages, whether spoken, written, signed, or otherwise signaled, for the purpose of communication. Language tag syntax is defined by the IETF's BCP 47
This library implements all subtags from the BCP47 (RFC 5646) specification. Subtag enumerations are generated using code generation from the IANA Language Subtag Registry. Updating the subtag registry does not break the backward binary compatibility of this library.
Usage
Fields of LanguageTag
Language
- The primary language subtag is the first subtag in a language tagScript
- Script subtags are used to indicate the script or writing system variations that distinguish the written forms of a language or its dialectsRegion
- Region subtags are used to indicate linguistic variations associated with or appropriate to a specific country, territory, or region.Variants
- Variant subtags are used to indicate additional, well-recognized variations that define a language or its dialects that are not covered by other available subtags.Extensions
- Extensions provide a mechanism for extending language tags for use in various applications.PrivateUse
- Private use subtags are used to indicate distinctions in language that are important in a given context by private agreement.
Initialize
var en = Language.EN; // English language
var zh = Language.ZH; // Chinese language
var latn = Script.Latn; // Latin script
var hans = Script.Hans; // Han (Simplified variant)
var tw = Region.TW; // Taiwan, Province of China
// tag zh-Hans-TW
var tag1 = new LanguageTag(zh, hans, tw);
// tag zh-Latn-TW-Pinyin
var tag2 = new LanguageTag(zh, latn, tw, new []{ Variant.Pinyin });
// tag en-US-x-twain
var tag3 = new LanguageTag(en, Region.US, ExtensionSubtag.ForPrivateUse("twain"));
// tag de-DE-u-co-phonebk
var tag4 = new LanguageTag(
Language.DE,
Region.DE,
new []{ new ExtensionSubtag('u', "co", "phonebk") });
Parsing
var tag3 = LanguageTag.Parse("ru");
var tag4 = LanguageTag.Parse("zh-Hans-TW");
var tag5 = LanguageTag.Parse("en-GB-scotland");
Any operation
// Equals
Assert.True(tag1 == tag6);
// zh-Hans-TW -> zh-Hans
var tag8 = tag6.Take(LanguageTag.Field.Language | LanguageTag.Field.Script);
// zh-Hans is subset of zh-Hans-TW
Assert.True(tag8.IsSubsetOf(tag6));
Links to main documentation
- Tags for Identifying Languages: BCP 47, RFC 5646
- Language tags in HTML and XML: http://www.w3.org/International/articles/language-tags
- Choosing a Language Tag: http://www.w3.org/International/questions/qa-choosing-language-tags
- Understanding the New Language Tags: http://www.w3.org/International/articles/bcp47
- IANA Language Subtag Registry: http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on NLanguageTag:
Package | Downloads |
---|---|
Hsm.BaseTypes
This package provides HSM base types in .net projects. |
|
JtlSharp
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.