-
Notifications
You must be signed in to change notification settings - Fork 536
Added Russian, German and Spanish languages for ListItemTextGetter_* classes #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: vNext
Are you sure you want to change the base?
Changes from 6 commits
40ecae5
2d6b97e
18d2677
c7d1b85
0ccae9a
18c0294
c5088cf
98380f6
0062349
5daa880
0eaf752
47486cb
693e149
2ce9e16
e1ce32a
70c57d7
c894419
62050f1
91e5761
c0edc63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using Xunit; | ||
| using OpenXmlPowerTools; | ||
|
|
||
| #if !ELIDE_XUNIT_TESTS | ||
|
|
||
| namespace OpenXmlPowerTools.Tests | ||
| { | ||
| public class ListItemTextGetter_ru_RUTests | ||
| { | ||
| [Theory] | ||
| [InlineData(1, "1-ый")] | ||
| [InlineData(2, "2-ой")] | ||
| [InlineData(3, "3-ий")] | ||
| [InlineData(4, "4-ый")] | ||
| [InlineData(5, "5-ый")] | ||
| [InlineData(6, "6-ой")] | ||
| [InlineData(7, "7-ой")] | ||
| [InlineData(8, "8-ой")] | ||
| [InlineData(9, "9-ый")] | ||
| [InlineData(10, "10-ый")] | ||
| [InlineData(11, "11-ый")] | ||
| [InlineData(12, "12-ый")] | ||
| [InlineData(13, "13-ый")] | ||
| [InlineData(14, "14-ый")] | ||
| [InlineData(16, "16-ый")] | ||
| [InlineData(17, "17-ый")] | ||
| [InlineData(18, "18-ый")] | ||
| [InlineData(19, "19-ый")] | ||
| [InlineData(20, "20-ый")] | ||
| [InlineData(23, "23-ий")] | ||
| [InlineData(25, "25-ый")] | ||
| [InlineData(50, "50-ый")] | ||
| [InlineData(56, "56-ой")] | ||
| [InlineData(67, "67-ой")] | ||
| [InlineData(78, "78-ой")] | ||
| [InlineData(100, "100-ый")] | ||
| [InlineData(123, "123-ий")] | ||
| [InlineData(125, "125-ый")] | ||
| [InlineData(1050, "1050-ый")] | ||
| public void GetListItemText_Ordinal(int integer, string expectedText) | ||
| { | ||
| string actualText = ListItemTextGetter_ru_RU.GetListItemText("", integer, "ordinal"); | ||
|
|
||
| Assert.Equal(expectedText, actualText); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
|
|
||
| namespace OpenXmlPowerTools | ||
| { | ||
| public class ListItemTextGetter_de_DE | ||
| { | ||
| private static string[] OneThroughNineteen = { | ||
| "eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", | ||
| "nuen", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", | ||
| "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "nuenzehn" | ||
| }; | ||
|
|
||
| private static string[] Tens = { | ||
| "zehn", "zwanzig", "dreißig", "vierzig", "fünfzig", "sechzig", "siebzig", | ||
| "achtzig", "nuenzig" | ||
| }; | ||
|
|
||
| private static string[] OrdinalOneThroughNineteen = { | ||
| "erste", "zweite", "dritte", "vierte", "fünfte", "sechste", | ||
| "siebte", "achte", "nuente", "zehnte", "elfte", "zwölfte", | ||
| "dreizehnte", "vierzehnte", "fünfzehnte", "sechzehnte", | ||
| "siebzehnte", "achtzehnte", "nuenzehnte" | ||
| }; | ||
|
|
||
| private static string[] OrdinalTens = { | ||
| "zehnte", "zwanzigste", "dreißigste", "vierzigste", "fünfzigste", | ||
| "sechzigste", "siebzigste", "achtzigste", "nuenzigste" | ||
| }; | ||
|
|
||
| public static string GetListItemText(string languageCultureName, int levelNumber, string numFmt) | ||
| { | ||
| if (levelNumber > 19999) | ||
| throw new ArgumentOutOfRangeException("levelNumber", "Convering a levelNumber to ordinal text that is greater then 19 999 is not supported"); | ||
|
||
| if (levelNumber == 0) | ||
| return "Zero"; | ||
| if (levelNumber < 0) | ||
| throw new ArgumentOutOfRangeException("levelNumber", "Converting a negative levelNumber to ordinal text is not supported"); | ||
|
|
||
| if (numFmt == "ordinal") | ||
| return GetOrdinal(levelNumber); | ||
| if (numFmt == "cardinalText") | ||
| return GetCardinalText(levelNumber); | ||
| if (numFmt == "ordinalText") | ||
| return GetOrdinalText(levelNumber); | ||
| return null; | ||
| } | ||
|
|
||
| private static string GetOrdinal(int levelNumber) | ||
| { | ||
| string suffix; | ||
| if (levelNumber % 100 == 11) | ||
| suffix = "-te"; | ||
| else if (levelNumber % 10 == 1) | ||
| suffix = "-ste"; | ||
| else | ||
| suffix = "-te"; | ||
| return levelNumber.ToString() + suffix; | ||
| } | ||
|
|
||
| private static string GetCardinalText(int levelNumber) | ||
| { | ||
| string result = ""; | ||
|
|
||
| // Get thousands | ||
| int t1 = levelNumber / 1000; | ||
| int t2 = levelNumber % 1000; | ||
| if (t1 >= 1) | ||
| result += (t1 == 1 ? "ein" : OneThroughNineteen[t1 - 1]) + " thausend"; | ||
|
||
| if (t1 >= 1 && t2 == 0) | ||
| return result.Substring(0, 1).ToUpper() + result.Substring(1); | ||
| if (t1 >= 1) | ||
| result += " "; | ||
|
|
||
| // Get hundreds | ||
| int h1 = (levelNumber % 1000) / 100; | ||
| int h2 = levelNumber % 100; | ||
| if (h1 >= 1) | ||
| result += (h1 == 1 ? "ein" : OneThroughNineteen[h1 - 1]) + " hundert"; | ||
| if (h1 >= 1 && h2 == 0) | ||
| return result.Substring(0, 1).ToUpper() + result.Substring(1); | ||
| if (h1 >= 1) | ||
| result += " "; | ||
|
|
||
| // Tens and ones | ||
| int z = levelNumber % 100; | ||
| if (z <= 19) | ||
| result += OneThroughNineteen[z - 1]; | ||
| else | ||
| { | ||
| int x = z / 10; | ||
| int r = z % 10; | ||
| if (r >= 1) | ||
| result += (r == 1 ? "ein" : OneThroughNineteen[r - 1]) + "und"; | ||
| result += Tens[x - 1]; | ||
| } | ||
| return result.Substring(0, 1).ToUpper() + result.Substring(1); | ||
| } | ||
|
|
||
| private static string GetOrdinalText(int levelNumber) | ||
| { | ||
| string result = ""; | ||
|
|
||
| // Get thousands | ||
| int t1 = levelNumber / 1000; | ||
| int t2 = levelNumber % 1000; | ||
| if (t1 >= 1 && t2 != 0) | ||
| result += (t1 == 1 ? "ein" : OneThroughNineteen[t1 - 1]) + " thausend"; | ||
| if (t1 >= 1 && t2 == 0) | ||
| { | ||
| result += (t1 == 1 ? "ein" : OneThroughNineteen[t1 - 1]) + " thausendste"; | ||
| return result.Substring(0, 1).ToUpper() + result.Substring(1); | ||
| } | ||
| if (t1 >= 1) | ||
| result += " "; | ||
|
|
||
| // Get hundreds | ||
| int h1 = (levelNumber % 1000) / 100; | ||
| int h2 = levelNumber % 100; | ||
| if (h1 >= 1 && h2 != 0) | ||
| result += (h1 == 1 ? "ein" : OneThroughNineteen[h1 - 1]) + " hundert"; | ||
| if (h1 >= 1 && h2 == 0) | ||
| { | ||
| result += (h1 == 1 ? "ein" : OneThroughNineteen[h1 - 1]) + " hundertste"; | ||
| return result.Substring(0, 1).ToUpper() + result.Substring(1); | ||
| } | ||
| if (h1 >= 1) | ||
| result += " "; | ||
|
|
||
| // Get tens and ones | ||
| int z = levelNumber % 100; | ||
| if (z <= 19) | ||
| result += OrdinalOneThroughNineteen[z - 1]; | ||
| else | ||
| { | ||
| int x = z / 10; | ||
| int r = z % 10; | ||
| if (r >= 1) | ||
| result += (r == 1 ? "ein" : OneThroughNineteen[r - 1]) + "und"; | ||
| result += OrdinalTens[x - 1]; | ||
| } | ||
| return result.Substring(0, 1).ToUpper() + result.Substring(1); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please replace
nuenwithneuneverywhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I fixed that.