NLanguageTag 4.0.0

dotnet add package NLanguageTag --version 4.0.0                
NuGet\Install-Package NLanguageTag -Version 4.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NLanguageTag" Version="4.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NLanguageTag --version 4.0.0                
#r "nuget: NLanguageTag, 4.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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.

NuGet Version NuGet Downloads

Usage


Fields of LanguageTag

  • Language - The primary language subtag is the first subtag in a language tag
  • Script - Script subtags are used to indicate the script or writing system variations that distinguish the written forms of a language or its dialects
  • Region - 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));
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last updated
4.0.0 12,346 2/21/2024
3.2.0 49,348 3/20/2022
3.1.0 17,124 6/30/2021
3.0.0 361 6/30/2021
2.0.0 19,626 11/27/2019