private void UpdateAllLanguages() { var languageIds = languageSetter .GetAppLangIds().ToArray(); var languages = languageFactory.Get(languageIds) .OrderBy(l => l.Name).ToArray(); foreach (var language in languages) { AllLanguages.Add(language); } }
public static void LoadLanguages() { AllLanguages.Clear(); using (var webClient = new WebClient()) { string responcedString = webClient.DownloadString(SpecialPaths.LanguagesFilePath); foreach (var infoString in responcedString.Split('\n')) { var language = Language.GetLanguage(infoString); if (language != null) { AllLanguages.Add(language); } } } }
/// <summary> /// Starting point after click on Start Now button. Loads all source languages (first ComboBox). /// </summary> /// <param name="parameter"></param> /// <param name="mode"></param> /// <param name="suspensionState"></param> /// <returns></returns> public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState) { var languages = await new OxfordDictionaryMVVMService().GetLanguageAsync(); var results = languages.results; if (results == null) { return; } foreach (var lang in results) { // load only those, which has source and target language too if (lang.sourceLanguage != null && lang.targetLanguage != null) { AllLanguages.Add(lang); } } //Fire PropertyChangedEvent this.RaisePropertyChanged(nameof(AllLanguages)); await base.OnNavigatedToAsync(parameter, mode, suspensionState); }
private async void OnActivated(object sender, ActivationEventArgs activationEventArgs) { _config = _configService.GetEffectiveConfiguration(); var chocolateyFeatures = await _chocolateyService.GetFeatures(); foreach (var chocolateyFeature in chocolateyFeatures) { #if !DEBUG // We hide this during DEBUG as it is a dark feature var descriptionKey = "Chocolatey_" + chocolateyFeature.Name + "Description"; var newDescription = _translationSource[descriptionKey]; if (string.IsNullOrEmpty(newDescription)) { descriptionKey = chocolateyFeature.Description; newDescription = _translationSource[descriptionKey]; } if (!string.IsNullOrEmpty(newDescription)) { chocolateyFeature.Description = newDescription; _translationSource.PropertyChanged += (s, e) => { chocolateyFeature.Description = _translationSource[descriptionKey]; }; } #endif ChocolateyFeatures.Add(chocolateyFeature); } _changedChocolateyFeature = new Subject <ChocolateyFeature>(); _changedChocolateyFeature .Select(f => Observable.FromAsync(() => UpdateChocolateyFeature(f))) .Concat() .Subscribe(); var chocolateySettings = await _chocolateyService.GetSettings(); foreach (var chocolateySetting in chocolateySettings) { #if !DEBUG // We hide this during DEBUG as it is a dark feature var descriptionKey = "Chocolatey_" + chocolateySetting.Key + "Description"; var newDescription = _translationSource[descriptionKey]; if (string.IsNullOrEmpty(newDescription)) { descriptionKey = chocolateySetting.Description; newDescription = _translationSource[descriptionKey]; } if (!string.IsNullOrEmpty(newDescription)) { chocolateySetting.Description = newDescription; _translationSource.PropertyChanged += (s, e) => { chocolateySetting.Description = _translationSource[descriptionKey]; }; } #endif ChocolateySettings.Add(chocolateySetting); } _changedChocolateySetting = new Subject <ChocolateySetting>(); _changedChocolateySetting .Select(s => Observable.FromAsync(() => UpdateChocolateySetting(s))) .Concat() .Subscribe(); var chocolateyGuiFeatures = _configService.GetFeatures(global: false, useResourceKeys: true); foreach (var chocolateyGuiFeature in chocolateyGuiFeatures) { chocolateyGuiFeature.DisplayTitle = _translationSource["ChocolateyGUI_" + chocolateyGuiFeature.Title + "Title"]; #if DEBUG var descriptionKey = string.Empty; #else var descriptionKey = "ChocolateyGUI_" + chocolateyGuiFeature.Title + "Description"; #endif var newDescription = _translationSource[descriptionKey]; if (string.IsNullOrEmpty(newDescription)) { descriptionKey = chocolateyGuiFeature.Description; newDescription = _translationSource[descriptionKey]; } if (!string.IsNullOrEmpty(newDescription)) { chocolateyGuiFeature.Description = newDescription; _translationSource.PropertyChanged += (s, e) => { chocolateyGuiFeature.DisplayTitle = _translationSource["ChocolateyGUI_" + chocolateyGuiFeature.Title + "Title"]; chocolateyGuiFeature.Description = _translationSource[descriptionKey]; }; } ChocolateyGuiFeatures.Add(chocolateyGuiFeature); } _changedChocolateyGuiFeature = new Subject <ChocolateyGuiFeature>(); _changedChocolateyGuiFeature .Select(s => Observable.FromAsync(() => UpdateChocolateyGuiFeature(s))) .Concat() .Subscribe(); var chocolateyGuiSettings = _configService.GetSettings(global: false, useResourceKeys: true); foreach (var chocolateyGuiSetting in chocolateyGuiSettings.Where(c => !string.Equals(c.Key, nameof(UseLanguage), StringComparison.OrdinalIgnoreCase))) { chocolateyGuiSetting.DisplayName = _translationSource["ChocolateyGUI_" + chocolateyGuiSetting.Key + "Title"]; #if DEBUG var descriptionKey = string.Empty; #else var descriptionKey = "ChocolateyGUI_" + chocolateyGuiSetting.Key + "Description"; #endif var newDescription = _translationSource[descriptionKey]; if (string.IsNullOrEmpty(newDescription)) { descriptionKey = chocolateyGuiSetting.Description; newDescription = _translationSource[descriptionKey]; } if (!string.IsNullOrEmpty(newDescription)) { chocolateyGuiSetting.Description = newDescription; _translationSource.PropertyChanged += (s, e) => { chocolateyGuiSetting.DisplayName = _translationSource["ChocolateyGUI_" + chocolateyGuiSetting.Key + "Title"]; chocolateyGuiSetting.Description = _translationSource[descriptionKey]; }; } ChocolateyGuiSettings.Add(chocolateyGuiSetting); } _changedChocolateyGuiSetting = new Subject <ChocolateyGuiSetting>(); _changedChocolateyGuiSetting .Select(s => Observable.FromAsync(() => UpdateChocolateyGuiSetting(s))) .Concat() .Subscribe(); var sources = await _chocolateyService.GetSources(); foreach (var source in sources) { Sources.Add(source); } AllLanguages.Clear(); foreach (var language in Internationalization.GetAllSupportedCultures().OrderBy(c => c.NativeName)) { AllLanguages.Add(language); } var selectedLanguage = _config.UseLanguage; // We set it to the configuration itself, instead of the property // as we do not want to save the configuration file when it is not needed. _config.UseLanguage = Internationalization.GetSupportedCultureInfo(selectedLanguage).Name; NotifyOfPropertyChange(nameof(UseLanguage)); }