Пример #1
0
        public static string[] SelectLanguageWords(string name, string language)
        {
            WordList loadedList = WordList.LoadList(name);

            List <string> wordList = new List <string>();

            int languageCount = loadedList.Languages.Length;
            int languageIndex = 0;

            for (int i = 0; i < loadedList.Languages.Length; i++)
            {
                if (loadedList.Languages[i] == language.ToLower())
                {
                    languageIndex = i;
                    break;
                }
            }

            loadedList.List(languageIndex, translations =>
            {
                for (int i = languageIndex; i < translations.Length; i += languageCount)
                {
                    wordList.Add(translations[i]);
                }
            });

            return(wordList.ToArray());
        }
Пример #2
0
        public static IEnumerable <string[]> AllWords(string args)
        {
            WordList loadedList    = WordList.LoadList(args);
            int      languageCount = loadedList.Languages.Length;

            List <string> wordList = new List <string>();

            loadedList.List(0, translations =>
            {
                for (int i = 0; i < translations.Length; i++)
                {
                    wordList.Add(translations[i]);
                }
            });

            for (int row = 0; row < wordList.Count / languageCount; row++)
            {
                string[] words = new string[languageCount];

                for (int column = 0; column < languageCount; column++)
                {
                    words[column] = wordList[(row * languageCount) + column].Capitalize();
                }

                yield return(words);
            }
        }
Пример #3
0
        public static void Words(string[] args)
        {
            if (args.Length > 1)
            {
                if (File.Exists($"{WordList.LocalApplicationDirectory}{args[1]}.dat"))
                {
                    WordList loadedList = WordList.LoadList(args[1]);

                    if (loadedList.Count() != 0)
                    {
                        foreach (string language in loadedList.Languages)
                        {
                            Console.Write($"{language.ToUpper(),-15}");
                        }

                        int languageIndex = 0;

                        if (args.Length == 3)
                        {
                            for (int index = 0; index < loadedList.Languages.Length; index++)
                            {
                                if (loadedList.Languages[index] == args[2])
                                {
                                    languageIndex = index;
                                    break;
                                }
                            }
                        }

                        loadedList.List(languageIndex, translations =>
                        {
                            for (int i = 0; i < translations.Length; i++)
                            {
                                if (i % loadedList.Languages.Length == 0)
                                {
                                    Console.WriteLine();
                                }

                                Console.Write($"{translations[i],-15}");
                            }
                        });
                    }
                    else
                    {
                        Console.WriteLine("List doesn't contain any words.");
                    }
                }
                else
                {
                    Console.WriteLine("Could not find list.");
                }
            }
            else
            {
                Console.WriteLine("Please provide list name.");
            }
        }