public string Convert(int number, GrammaticalGender gender) { // it's easier to treat zero as a completely distinct case if (number == 0) return "zero"; else if (number == 1) // no prefixes for primul/prima return this.getPartByGender(_ordinalsUnder10[number], gender); else if (number <= 9) // units ordinals, 2 to 9, are totally different than the rest: treat them as a distinct case return string.Format("{0} {1}", gender == GrammaticalGender.Feminine ? _femininePrefix : _masculinePrefix, this.getPartByGender(_ordinalsUnder10[number], gender) ); else { var coverter = new RomanianCardinalNumberConverter(); var words = coverter.Convert(number, gender); // remove 'de' preposition words = words.Replace(" de ", " "); if ((gender == GrammaticalGender.Feminine) && words.EndsWith("zeci")) { words = words.Substring(0, words.Length - 4) + "zece"; } else if ((gender == GrammaticalGender.Feminine) && words.Contains("zeci") && (words.Contains("milioane") || words.Contains("miliarde"))) { words = words.Replace("zeci", "zecea"); } if ((gender == GrammaticalGender.Feminine) && words.StartsWith("un ")) { words = words.Substring(2).TrimStart(); } if (words.EndsWith("milioane")) { if (gender == GrammaticalGender.Feminine) words = words.Substring(0, words.Length - 8) + "milioana"; } var customMasculineSuffix = _masculineSuffix; if (words.EndsWith("milion")) { if (gender == GrammaticalGender.Feminine) words = words.Substring(0, words.Length - 6) + "milioana"; else customMasculineSuffix = "u" + _masculineSuffix; } else if (words.EndsWith("miliard")) { if (gender == GrammaticalGender.Masculine) customMasculineSuffix = "u" + _masculineSuffix; } // trim last letter if ((gender == GrammaticalGender.Feminine) && (!words.EndsWith("zece") && (words.EndsWith("a") || words.EndsWith("ă") || words.EndsWith("e") || words.EndsWith("i")))) { words = words.Substring(0, words.Length - 1); } return string.Format("{0} {1}{2}", gender == GrammaticalGender.Feminine ? _femininePrefix : _masculinePrefix, words, gender == GrammaticalGender.Feminine ? _feminineSuffix : customMasculineSuffix ); } }
public override string Convert(int number, GrammaticalGender gender) { var converter = new RomanianCardinalNumberConverter(); return converter.Convert(number, gender); }
public string Convert(int number, GrammaticalGender gender) { // it's easier to treat zero as a completely distinct case if (number == 0) { return("zero"); } else if (number == 1) { // no prefixes for primul/prima return(this.getPartByGender(_ordinalsUnder10[number], gender)); } else if (number <= 9) { // units ordinals, 2 to 9, are totally different than the rest: treat them as a distinct case return(string.Format("{0} {1}", gender == GrammaticalGender.Feminine ? _femininePrefix : _masculinePrefix, this.getPartByGender(_ordinalsUnder10[number], gender) )); } else { var coverter = new RomanianCardinalNumberConverter(); var words = coverter.Convert(number, gender); // remove 'de' preposition words = words.Replace(" de ", " "); if ((gender == GrammaticalGender.Feminine) && words.EndsWith("zeci")) { words = words.Substring(0, words.Length - 4) + "zece"; } else if ((gender == GrammaticalGender.Feminine) && words.Contains("zeci") && (words.Contains("milioane") || words.Contains("miliarde"))) { words = words.Replace("zeci", "zecea"); } if ((gender == GrammaticalGender.Feminine) && words.StartsWith("un ")) { words = words.Substring(2).TrimStart(); } if (words.EndsWith("milioane")) { if (gender == GrammaticalGender.Feminine) { words = words.Substring(0, words.Length - 8) + "milioana"; } } var customMasculineSuffix = _masculineSuffix; if (words.EndsWith("milion")) { if (gender == GrammaticalGender.Feminine) { words = words.Substring(0, words.Length - 6) + "milioana"; } else { customMasculineSuffix = "u" + _masculineSuffix; } } else if (words.EndsWith("miliard")) { if (gender == GrammaticalGender.Masculine) { customMasculineSuffix = "u" + _masculineSuffix; } } // trim last letter if ((gender == GrammaticalGender.Feminine) && (!words.EndsWith("zece") && (words.EndsWith("a") || words.EndsWith("ă") || words.EndsWith("e") || words.EndsWith("i")))) { words = words.Substring(0, words.Length - 1); } return(string.Format("{0} {1}{2}", gender == GrammaticalGender.Feminine ? _femininePrefix : _masculinePrefix, words, gender == GrammaticalGender.Feminine ? _feminineSuffix : customMasculineSuffix )); } }
// Token: 0x060001F5 RID: 501 RVA: 0x0000BA10 File Offset: 0x00009C10 public string Convert(int number, GrammaticalGender gender) { if (number == 0) { return("zero"); } if (number == 1) { return(this.getPartByGender(this._ordinalsUnder10[number], gender)); } if (number <= 9) { return(string.Format("{0} {1}", new object[] { (gender == GrammaticalGender.Feminine) ? this._femininePrefix : this._masculinePrefix, this.getPartByGender(this._ordinalsUnder10[number], gender) })); } string words = new RomanianCardinalNumberConverter().Convert(number, gender); words = words.Replace(" de ", " "); if (gender == GrammaticalGender.Feminine && words.EndsWith("zeci")) { words = words.Substring(0, words.Length - 4) + "zece"; } else if (gender == GrammaticalGender.Feminine && words.Contains("zeci") && (words.Contains("milioane") || words.Contains("miliarde"))) { words = words.Replace("zeci", "zecea"); } if (gender == GrammaticalGender.Feminine && words.StartsWith("un ")) { words = words.Substring(2).TrimStart(new char[0]); } if (words.EndsWith("milioane") && gender == GrammaticalGender.Feminine) { words = words.Substring(0, words.Length - 8) + "milioana"; } string customMasculineSuffix = this._masculineSuffix; if (words.EndsWith("milion")) { if (gender == GrammaticalGender.Feminine) { words = words.Substring(0, words.Length - 6) + "milioana"; } else { customMasculineSuffix = "u" + this._masculineSuffix; } } else if (words.EndsWith("miliard") && gender == GrammaticalGender.Masculine) { customMasculineSuffix = "u" + this._masculineSuffix; } if (gender == GrammaticalGender.Feminine && !words.EndsWith("zece") && (words.EndsWith("a") || words.EndsWith("ă") || words.EndsWith("e") || words.EndsWith("i"))) { words = words.Substring(0, words.Length - 1); } return(string.Format("{0} {1}{2}", new object[] { (gender == GrammaticalGender.Feminine) ? this._femininePrefix : this._masculinePrefix, words, (gender == GrammaticalGender.Feminine) ? this._feminineSuffix : customMasculineSuffix })); }