public IEnumerable <string> GetInstalledLanguages() { /* * Locale[] locale = Locale.GetAvailableLocales(); * foreach(Locale loc in locale) * { * string s1 = loc.DisplayCountry; * string s2 = loc.DisplayLanguage; * string s3 = loc.DisplayName; * //System.Diagnostics.Debug.WriteLine(s2); * * LanguageAvailableResult res = speaker.IsLanguageAvailable(loc); * switch (res) * { * case LanguageAvailableResult.Available: * System.Diagnostics.Debug.WriteLine(s2); * //langAvailable.Add(loc.DisplayLanguage); * break; * case LanguageAvailableResult.CountryAvailable: * //langAvailable.Add(loc.DisplayLanguage); * break; * case LanguageAvailableResult.CountryVarAvailable: * //langAvailable.Add(loc.DisplayLanguage); * break; * } * } */ return(Locale.GetAvailableLocales().Select(a => a.Language).Distinct()); }
/// <summary> /// this gets the available language /// </summary> /// <returns> available language in local device </returns> private List <string> GetLanguages() { var langAvailable = new List <string> { "Default" }; // our spinner only wants to contain the languages supported by the tts and ignore the rest var localesAvailable = Locale.GetAvailableLocales().ToList(); foreach (var locale in localesAvailable) { LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale); switch (res) { case LanguageAvailableResult.Available: langAvailable.Add(locale.DisplayLanguage); break; case LanguageAvailableResult.CountryAvailable: langAvailable.Add(locale.DisplayLanguage); break; case LanguageAvailableResult.CountryVarAvailable: langAvailable.Add(locale.DisplayLanguage); break; } } langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList(); return(langAvailable); }
/// <summary> /// Get all installed and valide lanaguages /// </summary> /// <returns>List of CrossLocales</returns> public async Task <IEnumerable <CrossLocale> > GetInstalledLanguages() { await Init(); if (textToSpeech != null && initialized) { var version = (int)global::Android.OS.Build.VERSION.SdkInt; var isLollipop = version >= 21; if (isLollipop) { try { //in a different method as it can crash on older target/compile for some reason return(GetInstalledLanguagesLollipop()); } catch (Exception ex) { Console.WriteLine("Something went horribly wrong, defaulting to old implementation to get languages: " + ex); } } var languages = new List <CrossLocale>(); var allLocales = Locale.GetAvailableLocales(); foreach (var locale in allLocales) { try { var result = textToSpeech.IsLanguageAvailable(locale); if (result == LanguageAvailableResult.CountryAvailable) { languages.Add(new CrossLocale { Country = locale.Country, Language = locale.Language, DisplayName = locale.DisplayName }); } } catch (Exception ex) { Console.WriteLine("Error checking language; " + locale + " " + ex); } } return(languages.GroupBy(c => c.ToString()) .Select(g => g.First())); } else { return(Locale.GetAvailableLocales() .Where(a => !string.IsNullOrWhiteSpace(a.Language) && !string.IsNullOrWhiteSpace(a.Country)) .Select(a => new CrossLocale { Country = a.Country, Language = a.Language, DisplayName = a.DisplayName }) .GroupBy(c => c.ToString()) .Select(g => g.First())); } }
static IEnumerable <Language> FindInstalledLanguages() { return(Locale.GetAvailableLocales() .Where(a => a.Language.HasValue() && a.DisplayName.HasValue()) .Select(a => new Language { Id = a.Language, Name = a.DisplayName }) .GroupBy(c => c.Id) .Select(g => g.First())); }
internal Locale GetLocale() { if (Language == null) { return(Locale.Default); } var langs = Locale.GetAvailableLocales().ToList(); return(langs.FirstOrDefault(x => x.Language.Replace("_", "-").StartsWith(Language?.Id.ToLower())) ?? Locale.Default); }
public void InitializeLocaleList() { // referencing to the local var, the LangAvailable property can't be replaced, it's read-only _langList.Clear(); _langList.Add("Default"); // our spinner only wants to contain the languages supported by the tts and ignore the rest var localesAvailable = Locale.GetAvailableLocales().ToList(); foreach (var locale in localesAvailable) { LanguageAvailableResult res = _textToSpeech.IsLanguageAvailable(locale); if (IsLocaleAvailable(locale)) { _langList.Add(locale.DisplayName); } } _langList = _langList.OrderBy(t => t).Distinct().ToList(); }
IEnumerable <Country> GetAvailableCountries() { foreach (var locale in Locale.GetAvailableLocales()) { if (string.IsNullOrEmpty(locale.Country) || string.IsNullOrWhiteSpace(locale.DisplayCountry)) { continue; } var drawable = GetCountryFlag(locale.Country); if (drawable <= 0) { continue; } yield return(new Country { Iso = locale.Country, Name = locale.DisplayCountry, Code = string.Format("+{0}", _phoneUtil.GetCountryCodeForRegion(locale.Country)), FlagId = drawable }); } }
/// <summary> /// Gets the list of installed Locales which support DateFormat. /// </summary> /// /// <returns>an array of Locale</returns> public static Locale[] GetAvailableLocales() { return(Locale.GetAvailableLocales()); }
/// <summary> /// Get installed languages. /// </summary> /// <returns> /// The installed language names. /// </returns> public IEnumerable <string> GetInstalledLanguages() { return(Locale.GetAvailableLocales().Select(a => a.Language).Distinct()); }
public void UpdateLocale(int id) { SelectedLocale = Locale.GetAvailableLocales().FirstOrDefault( t => t.DisplayName == LangAvailable[id]); }
public IEnumerable <CrossLocale> GetCrossLocales() { return(Locale.GetAvailableLocales().Select(a => new CrossLocale { Country = a.Country, Language = a.Language, DisplayName = a.DisplayName })); }