Esempio n. 1
0
 private void ScanTranslations()
 {
     FileUtils.ScanPrefabsFoldersDirectoryNoLoad("kf_translationFiles", (path, pack, asset) =>
     {
         foreach (string lang in KlyteLocaleManager.locales)
         {
             foreach (string file in Directory.GetFiles($"{KlyteLocaleManager.m_translateFilesPath}{lang}{Path.DirectorySeparatorChar}", $"9_KF_*.txt"))
             {
                 File.Delete(file);
             }
             string fileName = Path.Combine(path, $"{lang}.txt");
             LogUtils.DoLog("PATH: " + fileName);
             if (File.Exists(fileName))
             {
                 string content = File.ReadAllText(fileName);
                 if (content != null)
                 {
                     File.WriteAllText($"{KlyteLocaleManager.m_translateFilesPath}{lang}{Path.DirectorySeparatorChar}9_KF_{(asset.isWorkshopAsset ? $"{(~pack.GetPublishedFileID().AsUInt64).ToString("00000000000000000")}_{asset.name}" : asset.name)}.txt", content);
                 }
             }
         }
     });
     KlyteLocaleManager.ReloadLanguage(true);
     m_alreadyLoadedTranslations = true;
 }
Esempio n. 2
0
        public void OnSettingsUI(UIHelperBase helperDefault)
        {
            m_onSettingsUiComponent = new UIHelperExtension((UIHelper)helperDefault).Self ?? m_onSettingsUiComponent;

            if (Locale.Get(KlyteLocaleManager.m_defaultTestKey) != "OK" || Locale.Get(KlyteLocaleManager.m_defaultModControllingKey) == CommonProperties.ModName)
            {
                if (Locale.Get(KlyteLocaleManager.m_defaultModControllingKey) != CommonProperties.ModName)
                {
                    KlyteMonoUtils.CreateElement <KlyteLocaleManager>(new GameObject(typeof(U).Name).transform);
                    if (Locale.Get(KlyteLocaleManager.m_defaultTestKey) != "OK")
                    {
                        LogUtils.DoErrorLog("CAN'T LOAD LOCALE!!!!!");
                    }
                    LocaleManager.eventLocaleChanged += KlyteLocaleManager.ReloadLanguage;
                }

                m_showLangDropDown = true;
            }
            foreach (string lang in KlyteLocaleManager.locales)
            {
                string content = KlyteResourceLoader.LoadResourceString($"UI.i18n.{lang}.properties");
                if (content != null)
                {
                    File.WriteAllText($"{KlyteLocaleManager.m_translateFilesPath}{lang}{Path.DirectorySeparatorChar}1_{Assembly.GetExecutingAssembly().GetName().Name}.txt", content);
                }
                content = KlyteResourceLoader.LoadResourceString($"commons.UI.i18n.{lang}.properties");
                if (content != null)
                {
                    File.WriteAllText($"{KlyteLocaleManager.m_translateFilesPath}{lang}{Path.DirectorySeparatorChar}0_common_{K45DialogControl.VERSION}.txt", content);
                }
            }
            KlyteLocaleManager.ReloadLanguage(true);
            DoWithSettingsUI(new UIHelperExtension(m_onSettingsUiComponent));
        }
Esempio n. 3
0
        protected void CreateGroup9(UIHelperExtension helper)
        {
            UIHelperExtension group9 = helper.AddGroupExtended(Locale.Get("K45_BETAS_EXTRA_INFO"));

            Group9SettingsUI(group9);

            group9.AddCheckbox(Locale.Get("K45_DEBUG_MODE"), DebugMode.value, delegate(bool val)
                               { DebugMode.value = val; });
            group9.AddLabel(string.Format(Locale.Get("K45_VERSION_SHOW"), FullVersion));
            group9.AddButton(Locale.Get("K45_RELEASE_NOTES"), delegate()
            {
                ShowVersionInfoPopup(true);
            });
            group9.AddButton("Report-a-bug helper", () => K45DialogControl.ShowModal(new K45DialogControl.BindProperties()
            {
                icon    = IconName,
                title   = "Report-a-bug helper",
                message = "If you find any problem with this mod, please send me the output_log.txt (or player.log on Mac/Linux) in the mod Workshop page. If applies, a printscreen can help too to make a better guess about what is happening wrong here...\n\n" +
                          "There's a link for a Workshop guide by <color #008800>aubergine18</color> explaining how to find your log file, depending of OS you're using.\nFeel free to create a topic at Workshop or just leave a comment linking your files.",
                showButton1 = true,
                textButton1 = "Okay...",
                showButton2 = true,
                textButton2 = "Go to the guide",
                showButton3 = true,
                textButton3 = "Go to mod page"
            }, (x) =>
            {
                if (x == 2)
                {
                    ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=463645931");
                    return(false);
                }
                if (x == 3)
                {
                    ColossalFramework.Utils.OpenUrlThreaded("https://steamcommunity.com/sharedfiles/filedetails/?id=" + ModId);
                    return(false);
                }
                return(true);
            }));

            if (m_showLangDropDown)
            {
                UIDropDown dd = null;
                dd = group9.AddDropdownLocalized("K45_MOD_LANG", (new string[] { "K45_GAME_DEFAULT_LANGUAGE" }.Concat(KlyteLocaleManager.locales.Select(x => $"K45_LANG_{x}")).Select(x => Locale.Get(x))).ToArray(), KlyteLocaleManager.GetLoadedLanguage(), delegate(int idx)
                {
                    KlyteLocaleManager.SaveLoadedLanguage(idx);
                    KlyteLocaleManager.ReloadLanguage();
                    KlyteLocaleManager.RedrawUIComponents();
                });
            }
            else
            {
                group9.AddLabel(string.Format(Locale.Get("K45_LANG_CTRL_MOD_INFO"), Locale.Get("K45_MOD_CONTROLLING_LOCALE")));
            }
        }
        public static void DoLocaleDump()
        {
            string localeDump = "LOCALE DUMP:\r\n";

            try
            {
                var locale = KlyteLocaleManager.m_localeStringsDictionary(KlyteLocaleManager.m_localeManagerLocale(LocaleManager.instance));
                foreach (Locale.Key k in locale.Keys)
                {
                    localeDump += string.Format("{0}  =>  {1}\n", k.ToString(), locale[k]);
                }
            }
            catch (Exception e)
            {
                LogUtils.DoErrorLog("LOCALE DUMP FAIL: {0}", e.ToString());
            }
            Debug.LogWarning(localeDump);
        }