예제 #1
0
 private void TranslatePage(TranslationConfigs translationPackageCheck, string _language)
 {
     if (translationPackageCheck.PackageExistsForLanguage(_language, "kgp"))
     {
         TranslateItems(new PageTranslations(), _language);
     }
     else
     {
         Frame.Navigate(typeof(MainPage));
     }
 }
예제 #2
0
 private async Task ProcessTranslation(string language, List<Package> packages, TranslationConfigs translationService)
 {
     foreach (Package package in packages)
     {
         await translationService.GetTranslationConfigsFromService(language, package.code);
     }
 }
예제 #3
0
 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;
     }
 }
예제 #4
0
        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();
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }