/net-cldr

Processing locale data for internationalisation software using Unicode CLDR

Primary LanguageC#MIT LicenseMIT

Sepia.Globalization

build status travis build Coverage Status NuGet docs

Provides locale content for internationalisation software using the Unicode Common Local Data Repository (CLDR).

Features

Getting started

Published releases of the package are available on NuGet. To install, run the following command in the Package Manager Console.

PM> Install-Package Sepia.Globalization

Usage

using Sepia.Globalization;

The CLDR uses the singleton pattern. To access the repository, use Cldr.Instance.

Ensure that the latest version of the CLDR is installed. This will download the latest published release from unicode.org, if required.

var version = Cldr.Instance.DownloadLatestAsync().Result;
Console.WriteLine($"Using CLDR {version}");

Query

Query the CLDR for the fractional digits of the Japanese Yen (JPY)

var jpy = Cldr.Instance
    .GetDocuments("common/supplemental/supplementalData.xml")
    .FirstElement("supplementalData/currencyData/fractions/info[@iso4217='JPY']");
Assert.AreEqual("0", jpy.Attribute("digits").Value);

Format

var locale = Locale.Create("fr");
var formatter = NumberFormatter.Create(locale);

Assert.AreEqual("1234,568", formatter.Format(1234.56789));

License

Copyright © Richard Schneider (makaretu@gmail.com)

The library is licensed under the MIT license. Refere to the LICENSE file for more information.

Buy Me A Coffee