static public int Refresh_s(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif LocalizationImporter.Refresh(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public void AddLocalizationSheet(LocalizationAsset localizationAsset) { var loc = _lockedAssetCache.Where(x => x.Value == localizationAsset || x.Value.TextAsset.text == localizationAsset.TextAsset.text).FirstOrDefault(); if (loc.Equals(default(KeyValuePair <string, LocalizationAsset>))) { return; } Localization.Instance.GetField <List <LocalizationAsset>, Localization>("inputFiles").Add(localizationAsset); LocalizationImporter.Refresh(); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { for (int index = 0; index < importedAssets.Length; index++) { var str = importedAssets[index]; if (str.EndsWith(".csv") && str.Contains("Localization")) { LocalizationImporter.Refresh(); } } }
public void AddLocalizationSheet(LocalizationAsset localizationAsset, bool shadow = false) { var loc = _lockedAssetCache.Where(x => x.Value.asset == localizationAsset || x.Value.asset.TextAsset.text == localizationAsset.TextAsset.text).FirstOrDefault(); if (loc.Equals(default(KeyValuePair <string, LocalizationAsset>))) { return; } Localization.Instance.InputFiles.Add(localizationAsset); LocalizationImporter.Refresh(); RecalculateLanguages(); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { for (int index = 0; index < importedAssets.Length; index++) { string str = importedAssets[index]; //Debug.Log("str: " + str); if (str.EndsWith(".lua") && str.Contains("localization")) { Debug.Log("LocalizationImporter.Refresh"); LocalizationImporter.Refresh(); } } }
public void Initialize() { SiraUtil.Utilities.AssemblyFromPath("ExtendedColorSchemes.Resources.locales.csv", out Assembly assembly, out string path); string content = SiraUtil.Utilities.GetResourceContent(assembly, path); var asset = new LocalizationAsset { Format = GoogleDriveDownloadFormat.CSV, TextAsset = new TextAsset(content) }; Localization.Instance.InputFiles.Add(asset); LocalizationImporter.Refresh(); }
public override void OnInspectorGUI() { if (refresh) { LocalizationImporter.Refresh(); refresh = false; } EditorGUI.BeginChangeCheck(); serializedObject.Update(); EditorGUILayout.LabelField("Polyglot Localization Settings", (GUIStyle)"IN TitleText"); var polyglotPath = GetPrefsString(PathPrefs); if (string.IsNullOrEmpty(polyglotPath)) { polyglotPath = DefaultPolyglotPath; } var changed = false; if (UpdateTextAsset("polyglotDocument", masterSheet)) { changed = true; masterSheet = null; } DisplayDocsAndSheetId("Official Polyglot Master", true, false, masterSheet, serializedObject.FindProperty("polyglotDocument"), OfficialSheet, OfficialGId, polyglotPath, DownloadMasterSheet); EditorGUILayout.Space(); if (UpdateTextAsset("customDocument", customSheet)) { changed = true; customSheet = null; } DisplayDocsAndSheetId("Custom Sheet", false, !ValidateDownloadCustomSheet(), customSheet, serializedObject.FindProperty("customDocument"), GetPrefsString(CustomDocsIdPrefs), GetPrefsString(CustomSheetIdPrefs), GetPrefsString(CustomPathPrefs), DownloadCustomSheet); EditorGUILayout.Space(); EditorGUILayout.LabelField("Localization Settings", (GUIStyle)"IN TitleText"); var iterator = serializedObject.GetIterator(); for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false) { if (iterator.propertyPath.Contains("Document")) { continue; } #if !ARABSUPPORT_ENABLED if (iterator.propertyPath == "Localize") { using (new EditorGUI.DisabledGroupScope(true)) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Arabic Support", (GUIStyle)"BoldLabel"); EditorGUILayout.HelpBox("Enable Arabic Support with ARABSUPPORT_ENABLED post processor flag", MessageType.Info); EditorGUILayout.Toggle(new GUIContent("Show Tashkeel", "Enable Arabic Support with ARABSUPPORT_ENABLED post processor flag"), true); EditorGUILayout.Toggle(new GUIContent("Use Hindu Numbers", "Enable Arabic Support with ARABSUPPORT_ENABLED post processor flag"), false); } } #endif using (new EditorGUI.DisabledScope("m_Script" == iterator.propertyPath)) EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]); } #if !ARABSUPPORT_ENABLED #endif serializedObject.ApplyModifiedProperties(); if (changed || EditorGUI.EndChangeCheck()) { refresh = true; } }
public async void Initialize() { #if DEBUG Stopwatch stopwatch = Stopwatch.StartNew(); #endif int successCount = 0; foreach (var source in _config.Localization.Sources.Where(s => s.Value.Enabled == true)) { WebResponse response = await _webClient.GetAsync(source.Value.URL, CancellationToken.None); if (response.IsSuccessStatusCode) { try { if (!_lockedAssetCache.TryGetValue(source.Key, out LocalizationAsset asset)) { using (MemoryStream ms = new MemoryStream(response.ContentToBytes())) { using (StreamReader reader = new StreamReader(ms)) { asset = new LocalizationAsset { Format = source.Value.Format, TextAsset = new TextAsset(response.ContentToString()) }; } } _lockedAssetCache.Add(source.Key, asset); Localization.Instance.GetField <List <LocalizationAsset>, Localization>("inputFiles").Add(asset); LocalizationImporter.Refresh(); } successCount++; } catch { Plugin.Log.Warn($"Could not parse localization data from {source.Key}"); continue; } } else { Plugin.Log.Warn($"Could not fetch localization data from {source.Key}"); } } #if DEBUG stopwatch.Stop(); Plugin.Log.Info($"Took {stopwatch.Elapsed.TotalSeconds} seconds to download, parse, and load {successCount} localization sheets."); #endif CheckLanguages(); /*List<string> keys = LocalizationImporter.GetKeys(); * * string savePath = Path.Combine(UnityGame.UserDataPath, "SiraUtil", "Localization", "Dumps"); * if (!Directory.Exists(savePath)) * { * Directory.CreateDirectory(savePath); * } * File.WriteAllLines(Path.Combine(savePath, "Keys.txt"), keys.ToArray());*/ /* * List<string> english = new List<string>(); * foreach (var key in keys) * { * var contains = LocalizationImporter.GetLanguagesContains(key); * english.Add(contains[key].First()); * } * File.WriteAllLines(Path.Combine(savePath, "English.txt"), english.ToArray()); */ /* * Localization.Instance.GetField<List<Language>, Localization>("supportedLanguages").Add(Language.French); * Localization.Instance.SelectedLanguage = Language.French;*/ }