Beispiel #1
0
        // Token: 0x0600013E RID: 318 RVA: 0x000041D0 File Offset: 0x000023D0
        private string Convert(int number, bool isOrdinal)
        {
            if (number == 0)
            {
                return(AfrikaansNumberToWordsConverter.GetUnitValue(0, isOrdinal));
            }
            if (number < 0)
            {
                return(string.Format("minus {0}", new object[]
                {
                    this.Convert((long)(-(long)number))
                }));
            }
            List <string> parts = new List <string>();

            if (number / 1000000000 > 0)
            {
                parts.Add(string.Format("{0} miljard", new object[]
                {
                    this.Convert((long)(number / 1000000000))
                }));
                number %= 1000000000;
            }
            if (number / 1000000 > 0)
            {
                parts.Add(string.Format("{0} miljoen", new object[]
                {
                    this.Convert((long)(number / 1000000))
                }));
                number %= 1000000;
            }
            if (number / 1000 > 0)
            {
                parts.Add(string.Format("{0} duisend", new object[]
                {
                    this.Convert((long)(number / 1000))
                }));
                number %= 1000;
            }
            if (number / 100 > 0)
            {
                parts.Add(string.Format("{0} honderd", new object[]
                {
                    this.Convert((long)(number / 100))
                }));
                number %= 100;
            }
            if (number > 0)
            {
                if (number < 20)
                {
                    if (parts.Count > 0)
                    {
                        parts.Add("en");
                    }
                    parts.Add(AfrikaansNumberToWordsConverter.GetUnitValue(number, isOrdinal));
                }
                else
                {
                    int    lastPartValue = number / 10 * 10;
                    string lastPart      = AfrikaansNumberToWordsConverter.TensMap[number / 10];
                    if (number % 10 > 0)
                    {
                        lastPart = string.Format("{0} en {1}", new object[]
                        {
                            AfrikaansNumberToWordsConverter.GetUnitValue(number % 10, false),
                            isOrdinal ? AfrikaansNumberToWordsConverter.GetUnitValue(lastPartValue, isOrdinal) : lastPart
                        });
                    }
                    else if (number % 10 == 0)
                    {
                        lastPart = string.Format("{0}{1}{2}", new object[]
                        {
                            (parts.Count > 0) ? "en " : "",
                            lastPart,
                            isOrdinal ? "ste" : ""
                        });
                    }
                    else if (isOrdinal)
                    {
                        lastPart = lastPart.TrimEnd(new char[]
                        {
                            '~'
                        }) + "ste";
                    }
                    parts.Add(lastPart);
                }
            }
            else if (isOrdinal)
            {
                List <string> list  = parts;
                int           index = parts.Count - 1;
                list[index] += "ste";
            }
            string toWords = string.Join(" ", parts.ToArray());

            if (isOrdinal)
            {
                toWords = AfrikaansNumberToWordsConverter.RemoveOnePrefix(toWords);
            }
            return(toWords);
        }