Inheritance: Humanizer.Localisation.NumberToWords.GenderedNumberToWordsConverter
コード例 #1
0
        // Token: 0x060001D8 RID: 472 RVA: 0x0000AA0C File Offset: 0x00008C0C
        private static void CollectParts(ICollection <string> parts, ref int number, int divisor, GrammaticalGender gender, params string[] forms)
        {
            if (number < divisor)
            {
                return;
            }
            int result = number / divisor;

            number %= divisor;
            UkrainianNumberToWordsConverter.CollectPartsUnderOneThousand(parts, result, gender);
            parts.Add(UkrainianNumberToWordsConverter.ChooseOneForGrammaticalNumber(result, forms));
        }
コード例 #2
0
        // Token: 0x060001D4 RID: 468 RVA: 0x0000A660 File Offset: 0x00008860
        public override string Convert(long input, GrammaticalGender gender)
        {
            if (input > 2147483647L || input < -2147483648L)
            {
                throw new NotImplementedException();
            }
            int number = (int)input;

            if (number == 0)
            {
                return("нуль");
            }
            List <string> parts = new List <string>();

            if (number < 0)
            {
                parts.Add("мінус");
                number = -number;
            }
            UkrainianNumberToWordsConverter.CollectParts(parts, ref number, 1000000000, GrammaticalGender.Masculine, new string[]
            {
                "мільярд",
                "мільярда",
                "мільярдів"
            });
            UkrainianNumberToWordsConverter.CollectParts(parts, ref number, 1000000, GrammaticalGender.Masculine, new string[]
            {
                "мільйон",
                "мільйона",
                "мільйонів"
            });
            UkrainianNumberToWordsConverter.CollectParts(parts, ref number, 1000, GrammaticalGender.Feminine, new string[]
            {
                "тисяча",
                "тисячі",
                "тисяч"
            });
            if (number > 0)
            {
                UkrainianNumberToWordsConverter.CollectPartsUnderOneThousand(parts, number, gender);
            }
            return(string.Join(" ", parts));
        }
コード例 #3
0
        // Token: 0x060001D9 RID: 473 RVA: 0x0000AA40 File Offset: 0x00008C40
        private static void CollectOrdinalParts(ICollection <string> parts, ref int number, int divisor, GrammaticalGender gender, string prefixedForm, params string[] forms)
        {
            if (number < divisor)
            {
                return;
            }
            int result = number / divisor;

            number %= divisor;
            if (number != 0)
            {
                UkrainianNumberToWordsConverter.CollectPartsUnderOneThousand(parts, result, gender);
                parts.Add(UkrainianNumberToWordsConverter.ChooseOneForGrammaticalNumber(result, forms));
                return;
            }
            if (result == 1)
            {
                parts.Add(prefixedForm);
                return;
            }
            parts.Add(UkrainianNumberToWordsConverter.GetPrefix(result) + prefixedForm);
        }
コード例 #4
0
        // Token: 0x060001D5 RID: 469 RVA: 0x0000A744 File Offset: 0x00008944
        public override string ConvertToOrdinal(int number, GrammaticalGender gender)
        {
            if (number == 0)
            {
                return("нульов" + UkrainianNumberToWordsConverter.GetEndingForGender(gender, number));
            }
            List <string> parts = new List <string>();

            if (number < 0)
            {
                parts.Add("мінус");
                number = -number;
            }
            UkrainianNumberToWordsConverter.CollectOrdinalParts(parts, ref number, 1000000000, GrammaticalGender.Masculine, "мільярдн" + UkrainianNumberToWordsConverter.GetEndingForGender(gender, number), new string[]
            {
                "мільярд",
                "мільярда",
                "мільярдів"
            });
            UkrainianNumberToWordsConverter.CollectOrdinalParts(parts, ref number, 1000000, GrammaticalGender.Masculine, "мільйонн" + UkrainianNumberToWordsConverter.GetEndingForGender(gender, number), new string[]
            {
                "мільйон",
                "мільйона",
                "мільйонів"
            });
            UkrainianNumberToWordsConverter.CollectOrdinalParts(parts, ref number, 1000, GrammaticalGender.Feminine, "тисячн" + UkrainianNumberToWordsConverter.GetEndingForGender(gender, number), new string[]
            {
                "тисяча",
                "тисячі",
                "тисяч"
            });
            if (number >= 100)
            {
                string ending   = UkrainianNumberToWordsConverter.GetEndingForGender(gender, number);
                int    hundreds = number / 100;
                number %= 100;
                if (number == 0)
                {
                    parts.Add(UkrainianNumberToWordsConverter.UnitsOrdinalPrefixes[hundreds] + "сот" + ending);
                }
                else
                {
                    parts.Add(UkrainianNumberToWordsConverter.HundredsMap[hundreds]);
                }
            }
            if (number >= 20)
            {
                string ending2 = UkrainianNumberToWordsConverter.GetEndingForGender(gender, number);
                int    tens    = number / 10;
                number %= 10;
                if (number == 0)
                {
                    parts.Add(UkrainianNumberToWordsConverter.TensOrdinal[tens] + ending2);
                }
                else
                {
                    parts.Add(UkrainianNumberToWordsConverter.TensMap[tens]);
                }
            }
            if (number > 0)
            {
                parts.Add(UkrainianNumberToWordsConverter.UnitsOrdinal[number] + UkrainianNumberToWordsConverter.GetEndingForGender(gender, number));
            }
            return(string.Join(" ", parts));
        }
コード例 #5
0
 // Token: 0x060001DB RID: 475 RVA: 0x0000AAA7 File Offset: 0x00008CA7
 private static string ChooseOneForGrammaticalNumber(int number, string[] forms)
 {
     return(forms[UkrainianNumberToWordsConverter.GetIndex(RussianGrammaticalNumberDetector.Detect(number))]);
 }