-
Notifications
You must be signed in to change notification settings - Fork 513
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
Added Russian, German and Spanish languages for ListItemTextGetter_* classes #44
Open
alexeysp11
wants to merge
20
commits into
OpenXmlDev:vNext
Choose a base branch
from
alexeysp11:vNext
base: vNext
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
40ecae5
added netcoreapp3.1
alexeysp11 2d6b97e
edited ListItemTextGetter_ru_RU
alexeysp11 18d2677
GetListItemText: russian and german
alexeysp11 c7d1b85
GetListItemText: naming
alexeysp11 0ccae9a
added ListItemTextGetter_es_ES
alexeysp11 18c0294
added validation for ListItemTextGetter
alexeysp11 c5088cf
fixed typos in ListItemTextGetter_de_DE
alexeysp11 98380f6
Replace 'Convering' with 'Converting'
alexeysp11 0062349
write '19 999' as '19999'
alexeysp11 5daa880
tested cardinal text in russian
alexeysp11 0eaf752
edited TargetFrameworks in test project file
alexeysp11 47486cb
tested ordinal text in russian
alexeysp11 693e149
tested class for german
alexeysp11 2ce9e16
fixed typos: replace 'greater then 19999' with 'greater than 19999'
alexeysp11 e1ce32a
fixed typos: tested class for spanish
alexeysp11 70c57d7
fixed typos: tested class for spanish
alexeysp11 c894419
fixed typos: edited exception text for languages
alexeysp11 62050f1
fixed typos: fixed typos (`greater then` -> `greater than`)
alexeysp11 91e5761
fixed typos: comments in language-related files
alexeysp11 c0edc63
Merge pull request #1 from alexeysp11/newlanguagestests
alexeysp11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
"neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", | ||
"fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn" | ||
}; | ||
|
||
private static string[] Tens = { | ||
"zehn", "zwanzig", "dreißig", "vierzig", "fünfzig", "sechzig", "siebzig", | ||
"achtzig", "neunzig" | ||
}; | ||
|
||
private static string[] OrdinalOneThroughNineteen = { | ||
"erste", "zweite", "dritte", "vierte", "fünfte", "sechste", | ||
"siebte", "achte", "neunte", "zehnte", "elfte", "zwölfte", | ||
"dreizehnte", "vierzehnte", "fünfzehnte", "sechzehnte", | ||
"siebzehnte", "achtzehnte", "neunzehnte" | ||
}; | ||
|
||
private static string[] OrdinalTens = { | ||
"zehnte", "zwanzigste", "dreißigste", "vierzigste", "fünfzigste", | ||
"sechzigste", "siebzigste", "achtzigste", "neunzigste" | ||
}; | ||
|
||
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]) + " tausend"; | ||
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]) + " tausend"; | ||
if (t1 >= 1 && t2 == 0) | ||
{ | ||
result += (t1 == 1 ? "ein" : OneThroughNineteen[t1 - 1]) + " tausendste"; | ||
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Replace
Convering
withConverting
in all of the language-related files of the commit. I recommend to write "19 999" as "19999" because the thausand separator is different in different languages (in English it is a,
).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, done. I also found and fixed a few more typos in the code. Additionally, I added tests for German and Spanish.