private async Task LoadSupportedLanguagesAsync()
        {
            try
            {
                SupportedLanguages supportedLanguages = await this.translatorTextService.GetSupportedLanguagesAsync();

                this.alternativeTranslationDict = supportedLanguages.Dictionary.ToDictionary(l => l.Key, l => l.Value.Translations);
                List <Language> translationLanguageList = supportedLanguages.Translation
                                                          .Select(v =>
                {
                    Language translationLang = v.Value;
                    translationLang.Code     = v.Key;
                    return(translationLang);
                })
                                                          .OrderBy(v => v.Name).ToList();

                InputLanguageCollection.AddRange(translationLanguageList);
                OutputLanguageCollection.AddRange(translationLanguageList);
                OutputLanguage = OutputLanguageCollection.FirstOrDefault(l => l.Code.Equals(DefaultLanguage.Code, StringComparison.OrdinalIgnoreCase));
            }
            catch (Exception ex)
            {
                await Util.GenericApiCallExceptionHandler(ex, "Failure loading languages.");
            }
        }
Example #2
0
        private async Task LoadSupportedLanguagesAsync()
        {
            try
            {
                SupportedLanguages supportedLanguages = await this.translatorTextService?.GetSupportedLanguagesAsync();

                if (supportedLanguages != null)
                {
                    List <LanguageDictionary> languageDictionaryList = supportedLanguages.Dictionary
                                                                       .Select(v =>
                    {
                        LanguageDictionary languageDict = v.Value;
                        languageDict.Code = v.Key;
                        return(languageDict);
                    })
                                                                       .OrderBy(v => v.Name)
                                                                       .ToList();
                    InputLanguageCollection.Clear();
                    InputLanguageCollection.AddRange(languageDictionaryList);
                }
            }
            catch (Exception ex)
            {
                await Util.GenericApiCallExceptionHandler(ex, "Failure loading languages.");
            }
        }