private void TranslatePage(TranslationConfigs translationPackageCheck, string _language) { if (translationPackageCheck.PackageExistsForLanguage(_language, "kgp")) { TranslateItems(new PageTranslations(), _language); } else { Frame.Navigate(typeof(MainPage)); } }
private async Task ProcessTranslation(string language, List<Package> packages, TranslationConfigs translationService) { foreach (Package package in packages) { await translationService.GetTranslationConfigsFromService(language, package.code); } }
private void TranslateButton(TranslationConfigs translationConfig, string _language, string _package, Button _packageButton, RelativePanel _packagePanel) { if (translationConfig.PackageExistsForLanguage(_language, _package)) { _packagePanel.Visibility = Visibility.Visible; _packageButton.Content = translationConfig.GetPackageTitleTranslation(_language, _package); } else { _packagePanel.Visibility = Visibility.Collapsed; } }
private async Task InitializeTranslations(Languages languages, TranslationConfigs translationService) { string listLanguage = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; string listLanguageName = CultureInfo.CurrentUICulture.NativeName; UpdateUI("downloading your first language, which happens to be " + listLanguageName + "\ngo to settings to add more languages"); await languages.CreateLanguageFile(new LanguageList()); UpdateUI("language list created"); List<Language> list = languages.GetLanguageListFromFile(new LanguageList()).Languages; //Populate Default language first UpdateUI("getting " + listLanguageName); await ProcessTranslation(listLanguage, list.Find(l => l.code == listLanguage).packages, translationService); if (await languages.IsLanguageDownloaded(listLanguage) == false) { UpdateUI(listLanguageName + " is downloading"); await languages.DownloadLanguage(listLanguage); } UpdateUI("looking at other languages\n\ngo to settings to download more languages"); foreach (Language language in list) { await ProcessTranslation(language.code, language.packages, translationService); } UpdateUI("done! moving on"); await CheckStatus(); }
public async Task DeleteLanguage(string language) { Language downloadLanguage = new Language(); TranslationConfigs translationService = new TranslationConfigs(); PageTranslations pageTranslationService = new PageTranslations(); downloadLanguage = await GetLanguage(language); foreach (Package package in downloadLanguage.packages) { IList<Page> pages = await translationService.GetTranslationConfig(downloadLanguage.code, package.code); foreach (Page page in pages) { pageTranslationService.DeletePageTranslation(downloadLanguage.code, package.code, page.filename); } } if (ApplicationData.Current.RoamingSettings.Values["primary"].ToString() == language) { string listLanguage = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; if (!await IsLanguageDownloaded(listLanguage)) { await DownloadLanguage(listLanguage); ChangeLanguageDownloadedFlag(listLanguage, languageListFileName, true); ChangeLanguageUpToDateFlag(listLanguage, languageListFileName, true); } ApplicationData.Current.RoamingSettings.Values["primary"] = listLanguage; } if (ApplicationData.Current.RoamingSettings.Values["current"].ToString() == language) { ApplicationData.Current.RoamingSettings.Values["current"] = ApplicationData.Current.RoamingSettings.Values["primary"]; } if (ApplicationData.Current.RoamingSettings.Values["parallel"].ToString() == language) { ApplicationData.Current.RoamingSettings.Values["parallel"] = ApplicationData.Current.RoamingSettings.Values["primary"]; } ChangeLanguageDownloadedFlag(language, languageListFileName, false); }
private async Task DownloadPackage(Language language, Package package, TranslationConfigs translationService, PageTranslations pageTranslationService, bool update) { IList<Page> pages = await translationService.GetTranslationConfig(language.code, package.code, true); foreach (Page page in pages) { await pageTranslationService.GetPageTranslationsFromService(language.code, package.code, page.filename, update); } ChangeVersion(language.code, languageListFileName, package); }
public async Task DownloadLanguage(string language, Package package, bool refresh = false) { Language downloadLanguage = new Language(); TranslationConfigs translationService = new TranslationConfigs(); PageTranslations pageTranslationService = new PageTranslations(); downloadLanguage = await GetLanguage(language); IList<Page> pages = await translationService.GetTranslationConfig(downloadLanguage.code, package.code, true); foreach (Page page in pages) { await pageTranslationService.GetPageTranslationsFromService(downloadLanguage.code, package.code, page.filename, refresh); } ChangeVersion(language, languageListFileName, package); ChangeLanguageDownloadedFlag(language, languageListFileName, true); ChangeLanguageUpToDateFlag(language, languageListFileName, true); }
public async Task DownloadLanguage(string language, bool update = false) { Language downloadLanguage = new Language(); TranslationConfigs translationService = new TranslationConfigs(); PageTranslations pageTranslationService = new PageTranslations(); if (update) { downloadLanguage = await GetTranslationFromWeb(language); } else { downloadLanguage = await GetLanguage(language); } foreach (Package package in downloadLanguage.packages) { await DownloadPackage(downloadLanguage, package, translationService, pageTranslationService, update); } ChangeLanguageDownloadedFlag(language, languageListFileName, true); ChangeLanguageUpToDateFlag(language, languageListFileName, true); }