GetListItemText_fr_FR.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // Copyright (c) Microsoft. All rights reserved.
  2. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. namespace OpenXmlPowerTools
  8. {
  9. public class ListItemTextGetter_fr_FR
  10. {
  11. private static string[] OneThroughNineteen = {
  12. "", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit",
  13. "neuf", "dix", "onze", "douze", "treize", "quatorze",
  14. "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf"
  15. };
  16. private static string[] Tens = {
  17. "", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "soixante-dix",
  18. "quatre-vingt", "quatre-vingt-dix"
  19. };
  20. private static string[] OrdinalOneThroughNineteen = {
  21. "", "unième", "deuxième", "troisième", "quatrième", "cinquième", "sixième",
  22. "septième", "huitième", "neuvième", "dixième", "onzième", "douzième",
  23. "treizième", "quatorzième", "quinzième", "seizième",
  24. "dix-septième", "dix-huitième", "dix-neuvième"
  25. };
  26. private static string[] OrdinalTenths = {
  27. "", "dixième", "vingtième", "trentième", "quarantième", "cinquantième",
  28. "soixantième", "soixante-dixième", "quatre-vingtième", "quatre-vingt-dixième"
  29. };
  30. private static string[] OrdinalTenthsPlus = {
  31. "", "", "vingt", "trente", "quarante", "cinquante",
  32. "soixante", "", "quatre-vingt", ""
  33. };
  34. public static string GetListItemText(string languageCultureName, int levelNumber, string numFmt)
  35. {
  36. if (numFmt == "cardinalText")
  37. {
  38. string result = "";
  39. var sLevel = (levelNumber + 10000).ToString();
  40. int thousands = int.Parse(sLevel.Substring(1, 1));
  41. int hundreds = int.Parse(sLevel.Substring(2, 1));
  42. int tens = int.Parse(sLevel.Substring(3, 1));
  43. int ones = int.Parse(sLevel.Substring(4, 1));
  44. /* exact thousands */
  45. if (levelNumber == 1000)
  46. return "Mille";
  47. if (levelNumber > 1000 && hundreds == 0 && tens == 0 && ones == 0)
  48. {
  49. result = OneThroughNineteen[thousands] + " mille";
  50. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  51. }
  52. /* > 1000 */
  53. if (levelNumber > 1000 && levelNumber < 2000)
  54. result = "mille ";
  55. else if (levelNumber > 2000 && levelNumber < 10000)
  56. result = OneThroughNineteen[thousands] + " mille ";
  57. /* exact hundreds */
  58. if (hundreds > 0 && tens == 0 && ones == 0)
  59. {
  60. if (hundreds == 1)
  61. result += "cent";
  62. else
  63. result += OneThroughNineteen[hundreds] + " cents";
  64. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  65. }
  66. /* > 100 */
  67. if (hundreds > 0)
  68. {
  69. if (hundreds == 1)
  70. result += "cent ";
  71. else
  72. result += OneThroughNineteen[hundreds] + " cent ";
  73. }
  74. /* exact tens */
  75. if (tens > 0 && ones == 0)
  76. {
  77. if (tens == 8)
  78. result += "quatre-vingts";
  79. else
  80. result += Tens[tens];
  81. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  82. }
  83. /* 71-79 */
  84. if (tens == 7)
  85. {
  86. if (ones == 1)
  87. result += Tens[6] + " et " + OneThroughNineteen[ones + 10];
  88. else
  89. result += Tens[6] + "-" + OneThroughNineteen[ones + 10];
  90. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  91. }
  92. /* 91-99 */
  93. if (tens == 9)
  94. {
  95. result += Tens[8] + "-" + OneThroughNineteen[ones + 10];
  96. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  97. }
  98. if (tens >= 2)
  99. {
  100. if (ones == 1 && tens != 8 && tens != 9)
  101. result += Tens[tens] + " et un";
  102. else
  103. result += Tens[tens] + "-" + OneThroughNineteen[ones];
  104. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  105. }
  106. if (levelNumber < 20)
  107. {
  108. result += OneThroughNineteen[tens * 10 + ones];
  109. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  110. }
  111. result += OneThroughNineteen[tens * 10 + ones];
  112. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  113. }
  114. if (numFmt == "ordinal")
  115. {
  116. string suffix;
  117. if (levelNumber == 1)
  118. suffix = "er";
  119. else
  120. suffix = "e";
  121. return levelNumber.ToString() + suffix;
  122. }
  123. if (numFmt == "ordinalText")
  124. {
  125. string result = "";
  126. if (levelNumber == 1)
  127. return "Premier";
  128. var sLevel = (levelNumber + 10000).ToString();
  129. int thousands = int.Parse(sLevel.Substring(1, 1));
  130. int hundreds = int.Parse(sLevel.Substring(2, 1));
  131. int tens = int.Parse(sLevel.Substring(3, 1));
  132. int ones = int.Parse(sLevel.Substring(4, 1));
  133. /* exact thousands */
  134. if (levelNumber == 1000)
  135. return "Millième";
  136. if (levelNumber > 1000 && hundreds == 0 && tens == 0 && ones == 0)
  137. {
  138. result = OneThroughNineteen[thousands] + " millième";
  139. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  140. }
  141. /* > 1000 */
  142. if (levelNumber > 1000 && levelNumber < 2000)
  143. result = "mille ";
  144. else if (levelNumber > 2000 && levelNumber < 10000)
  145. result = OneThroughNineteen[thousands] + " mille ";
  146. /* exact hundreds */
  147. if (hundreds > 0 && tens == 0 && ones == 0)
  148. {
  149. if (hundreds == 1)
  150. result += "centième";
  151. else
  152. result += OneThroughNineteen[hundreds] + " centième";
  153. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  154. }
  155. /* > 100 */
  156. if (hundreds > 0)
  157. {
  158. if (hundreds == 1)
  159. result += "cent ";
  160. else
  161. result += OneThroughNineteen[hundreds] + " cent ";
  162. }
  163. /* exact tens */
  164. if (tens > 0 && ones == 0)
  165. {
  166. result += OrdinalTenths[tens];
  167. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  168. }
  169. /* 71-79 */
  170. if (tens == 7)
  171. {
  172. if (ones == 1)
  173. result += OrdinalTenthsPlus[6] + " et " + OrdinalOneThroughNineteen[ones + 10];
  174. else
  175. result += OrdinalTenthsPlus[6] + "-" + OrdinalOneThroughNineteen[ones + 10];
  176. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  177. }
  178. /* 91-99 */
  179. if (tens == 9)
  180. {
  181. result += OrdinalTenthsPlus[8] + "-" + OrdinalOneThroughNineteen[ones + 10];
  182. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  183. }
  184. if (tens >= 2)
  185. {
  186. if (ones == 1 && tens != 8 && tens != 9)
  187. result += OrdinalTenthsPlus[tens] + " et unième";
  188. else
  189. result += OrdinalTenthsPlus[tens] + "-" + OrdinalOneThroughNineteen[ones];
  190. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  191. }
  192. if (levelNumber < 20)
  193. {
  194. result += OrdinalOneThroughNineteen[tens * 10 + ones];
  195. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  196. }
  197. result += OrdinalOneThroughNineteen[tens * 10 + ones];
  198. return result.Substring(0, 1).ToUpper() + result.Substring(1);
  199. }
  200. return null;
  201. }
  202. }
  203. }