CLDRs
Avalanche.Localization.Cldr.dll contains following rulesets:
RuleSet | Property | Description |
---|---|---|
Unicode.CLDR | Avalanche.Localization.CLDRs.CLDR | Newest ruleset |
Unicode.CLDR40 | Avalanche.Localization.CLDRs.CLDR40 | v40 |
Unicode.CLDR41 | Avalanche.Localization.CLDRs.CLDR41 | v41 |
Unicode.CLDR42 | Avalanche.Localization.CLDRs.CLDR42 | v42 |
Avalanche.Localization.Cldr is derived from plurals.xml and ordinals.xml of Unicode CLDR, and licensed as "Data files". Unicode CLDR is copyright of Unicode, Inc.
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE See Terms of Use for definitions of Unicode Inc.'s Data Files and Software. NOTICE TO USER: Carefully read the following legal agreement. BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE. COPYRIGHT AND PERMISSION NOTICE Copyright © 1991-2022 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in https://www.unicode.org/copyright.html. Permission is hereby granted, free of charge, to any person obtaining a copy of the Unicode data files and any associated documentation (the "Data Files") or Unicode software and any associated documentation (the "Software") to deal in the Data Files or Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Data Files or Software, and to permit persons to whom the Data Files or Software are furnished to do so, provided that either (a) this copyright and permission notice appear with all copies of the Data Files or Software, or (b) this copyright and permission notice appear in associated Documentation. THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE. Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in these Data Files or Software without prior written authorization of the copyright holder.
Add package reference.
<PropertyGroup>
<RestoreAdditionalProjectSources>https://avalanche.fi/Avalanche.Core/nupkg/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalanche.Localization.Cldr"/>
</ItemGroup>
CLDRs.CLDR contains latest CLDR rules.
IPluralRules rules = CLDRs.CLDR;
CLDRs.CLDR40 CLDR40 rules.
IPluralRules rules = CLDRs.CLDR40;
CLDRs.All contains all builtin CLDR rules.
IPluralRules rules = CLDRs.All;
CLDRs.PluralReader(filename, ruleset) creates reader that reads plurals.xml and ordinals.xml files.
IEnumerable<IPluralRule> reader = CLDRs.PluralReader("plurals.xml", "Unicode.CLDR40");
IPluralRules rules = new PluralRules(reader);
CLDRs.PluralReaders(path) creates reader that reads pluralsXX.xml and ordinalsXX.xml at a ''path''.
IEnumerable<IPluralRule> reader = CLDRs.PluralReaders(".");
IPluralRules rules = new PluralRules(reader);
CLDRs.All can be queried for an evaluator, and evaluator for pluralization case.
// Choose newest ruleset
string ruleset = PluralRuleInfo.NEWEST;
// Get 'de' rules evaluator for 'cardinal' values
IPluralRulesEvaluator evaluator = CLDRs.All.EvaluatorCached[(ruleset, "cardinal", "de", null, null)];
// Get culture
IFormatProvider culture = CultureInfo.GetCultureInfo("de");
// Create text
TextNumber textNumber = new TextNumber("100", culture);
// Evaluate plurality
IPluralRule[]? matches = evaluator.Evaluate<TextNumber>(textNumber);
// Get best matching plurality case
string? pluralityCase = matches?[0]?.Info.Case; // "other"