LocaleNames.Core
48.1.1
dotnet add package LocaleNames.Core --version 48.1.1
NuGet\Install-Package LocaleNames.Core -Version 48.1.1
<PackageReference Include="LocaleNames.Core" Version="48.1.1" />
<PackageVersion Include="LocaleNames.Core" Version="48.1.1" />
<PackageReference Include="LocaleNames.Core" />
paket add LocaleNames.Core --version 48.1.1
#r "nuget: LocaleNames.Core, 48.1.1"
#:package LocaleNames.Core@48.1.1
#addin nuget:?package=LocaleNames.Core&version=48.1.1
#tool nuget:?package=LocaleNames.Core&version=48.1.1
LocaleNames
Names of languages, countries and currencies in almost any language, for .NET. Look a name up by its code, or a code by its name.
The data comes from Unicode CLDR, is embedded in the package, and needs no network access or OS culture data. Targets netstandard2.0, net8.0 and net10.0.
Install
dotnet add package LocaleNames
LocaleNames is a meta package that references two others, which you can use on their own:
| Package | Contents |
|---|---|
LocaleNames.Core |
The code. Contains no data. |
LocaleNames.Data |
The CLDR data, embedded in an assembly. |
LocaleNames.Embed |
Build-time alternative to LocaleNames.Data, see below. |
Embedding the data into your own assembly
Reference LocaleNames.Embed instead of LocaleNames.Data and the data is embedded into your assembly during the build, so no extra assembly is deployed. You can embed only the locales you need:
<PropertyGroup>
<LocaleNamesEmbedLocales>cs;en;en_GB</LocaleNamesEmbedLocales>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LocaleNames.Embed" Version="..." />
</ItemGroup>
LocaleNames.Core finds the resources in loaded assemblies marked by the package. The mark is an assembly attribute generated by the SDK, so it is missing when GenerateAssemblyInfo is false. In that case, when you use LocaleNames.Core with LocaleNames.Embed (not the full LocaleNames or LocaleNames.Data), register the assembly yourself, once at startup, before the first lookup:
LocaleResourceProvider.Register(typeof(SomeTypeInYourAssembly).Assembly);
With the full LocaleNames package no registration is needed, LocaleNames.Data is found on its own. A registered assembly is searched before it, so registering one there deliberately overrides the data in LocaleNames.Data.
Usage
Get a translations object for the language you want the names in, then query it.
var cs = LocaleTranslationsFactory.ForLanguageCode("cs-CZ");
var en = LocaleTranslationsFactory.ForCultureInfo(new CultureInfo("en-US"));
Languages
en.FindLanguageName("cs-CZ"); // Czech
en.FindLanguageCode("Czech"); // cs
en.GetAllLanguageCodes();
Countries
en.FindCountryName("DE"); // Germany
en.FindCountryCode("Germany"); // DE
en.GetAllCountryCodes();
Currencies
cs.FindCurrencyName("CZK"); // česká koruna
cs.FindCurrencyName("CZK", PluralCategory.Few); // české koruny
cs.FindCurrencyPluralNames("CZK"); // all plural forms
cs.FindCurrencyCode("česká koruna"); // CZK
en.FindCurrencySymbol("CZK"); // CZK
en.FindCurrencySymbol("CZK", AltVariant.Narrow); // Kč
en.GetAllCurrencyCodes();
Contributing
Issues and pull requests are welcome. See CONTRIBUTING.md.
Activity
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. net9.0 was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.5)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on LocaleNames.Core:
| Package | Downloads |
|---|---|
|
LocaleNames
Localized names of languages, countries and currencies for .NET, with lookup in both directions. Powered by Unicode CLDR. |
|
|
LocaleNames.Embed
Embeds the LocaleNames CLDR data (names of languages, countries and currencies) directly into your assembly at build time, optionally only for selected locales. |
GitHub repositories
This package is not used by any popular GitHub repositories.