public static void loadTranslations <T>() { string text = Path.Combine(Application.persistentDataPath, "Translations"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } foreach (string path in Directory.GetFiles(text)) { string fileName = Path.GetFileName(path); string extension = Path.GetExtension(fileName); if (!(extension != ".trans")) { string value = File.ReadAllText(path); T t = JsonConvert.DeserializeObject <T>(value); SystemLanguage key = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), Path.GetFileNameWithoutExtension(fileName)); if (!key.Equals(null)) { Translation.translations.Add(key, (Translation)((object)t)); ((Translation)((object)t)).Init(); } } } if (Translation.translations.ContainsKey(Application.systemLanguage)) { Translation.mainTranslation = Translation.translations[Application.systemLanguage]; } else if (Translation.translations.ContainsKey(SystemLanguage.English)) { Translation.mainTranslation = Translation.translations[SystemLanguage.English]; } else { Translation.mainTranslation = (Translation)((object)Activator.CreateInstance <T>()); string contents = JsonConvert.SerializeObject((T)((object)Translation.mainTranslation), Formatting.Indented); File.WriteAllText(Path.Combine(text, SystemLanguage.English.ToString() + ".trans"), contents); Debug.Log("Stored to " + text); } }
void Awake() { if (instance) { DestroyImmediate(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); SystemLanguage deviceSystemLanguage = Application.systemLanguage; //이 device의 언어를 가져옴 systemLanguage = baseLanguage; foreach (SystemLanguage item in useLanguages) { if (deviceSystemLanguage.Equals(item)) { systemLanguage = item; } } foreach (SystemLanguage tLanguage in useLanguages) { textDic.Add(tLanguage, new List <string> ()); } TextAsset ta = Resources.Load <TextAsset> (textDataPath); string[] lines = ta.text.Split('\n'); foreach (string line in lines) { string[] words = line.Split('\t'); for (int i = 0; i < useLanguages.Length; i++) { textDic [useLanguages [i]].Add(words [i]); } } }
public override bool Equals(object obj) { var other = obj as ApplicationKun; if (other == null) { return(false); } if (!string.Equals(m_absoluteURL, other.m_absoluteURL)) { return(false); } if (!string.Equals(m_buildGUID, other.m_buildGUID)) { return(false); } if (!string.Equals(m_cloudProjectId, other.m_cloudProjectId)) { return(false); } if (!string.Equals(m_companyName, other.m_companyName)) { return(false); } if (!string.Equals(m_consoleLogPath, other.m_consoleLogPath)) { return(false); } if (!string.Equals(m_dataPath, other.m_dataPath)) { return(false); } if (!bool.Equals(m_genuine, other.m_genuine)) { return(false); } if (!bool.Equals(m_genuineCheckAvailable, other.m_genuineCheckAvailable)) { return(false); } if (!string.Equals(m_identifier, other.m_identifier)) { return(false); } if (!string.Equals(m_installerName, other.m_installerName)) { return(false); } if (!m_installMode.Equals(other.m_installMode)) { return(false); } if (!m_internetReachability.Equals(other.m_internetReachability)) { return(false); } if (!bool.Equals(m_isBatchMode, other.m_isBatchMode)) { return(false); } if (!bool.Equals(m_isConsolePlatform, other.m_isConsolePlatform)) { return(false); } if (!bool.Equals(m_isEditor, other.m_isEditor)) { return(false); } if (!bool.Equals(m_isFocused, other.m_isFocused)) { return(false); } if (!bool.Equals(m_isMobilePlatform, other.m_isMobilePlatform)) { return(false); } if (!bool.Equals(m_isPlaying, other.m_isPlaying)) { return(false); } if (!string.Equals(m_persistentDataPath, other.m_persistentDataPath)) { return(false); } if (!m_platform.Equals(other.m_platform)) { return(false); } if (!string.Equals(m_productName, other.m_productName)) { return(false); } if (!m_sandboxType.Equals(other.m_sandboxType)) { return(false); } if (!string.Equals(m_streamingAssetsPath, other.m_streamingAssetsPath)) { return(false); } if (!m_systemLanguage.Equals(other.m_systemLanguage)) { return(false); } if (!string.Equals(m_temporaryCachePath, other.m_temporaryCachePath)) { return(false); } if (!string.Equals(m_unityVersion, other.m_unityVersion)) { return(false); } if (!string.Equals(m_version, other.m_version)) { return(false); } if (!m_backgroundLoadingPriority.Equals(other.m_backgroundLoadingPriority)) { return(false); } if (!m_targetFrameRate.Equals(other.m_targetFrameRate)) { return(false); } if (!bool.Equals(m_runInBackground, other.m_runInBackground)) { return(false); } if (!bool.Equals(m_isDirty, other.m_isDirty)) { return(false); } return(true); }
void OnGUI() { GUIStyle titleStyle = new GUIStyle("button"); titleStyle.alignment = TextAnchor.MiddleCenter; titleStyle.fontSize = 20; titleStyle.fontStyle = FontStyle.Bold; GUIStyle centeredStyle = new GUIStyle(); centeredStyle.alignment = TextAnchor.MiddleCenter; GUIStyle centeredMediumStyle = new GUIStyle(); centeredMediumStyle.alignment = TextAnchor.MiddleCenter; centeredMediumStyle.fontSize = 15; centeredMediumStyle.fontStyle = FontStyle.Bold; GUIStyle leftMiddleStyle = new GUIStyle(); leftMiddleStyle.alignment = TextAnchor.MiddleLeft; leftMiddleStyle.fontSize = 15; leftMiddleStyle.fontStyle = FontStyle.Bold; GUIStyle enumPopup = new GUIStyle("popup"); enumPopup.alignment = TextAnchor.MiddleCenter; enumPopup.fontSize = 20; enumPopup.fontStyle = FontStyle.Bold; List <SystemLanguage> languageToRemove = new List <SystemLanguage>(); EditorGUILayout.BeginVertical(); { GUILayout.Label("Localization Editor Workspace v" + LanguageManager.VERSION, titleStyle); } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); if (!WorkspaceExists()) { EditorGUILayout.BeginHorizontal("box", GUILayout.Height(titleStyle.lineHeight)); { GUILayout.Label("Select Default Language:", titleStyle); EditorGUILayout.BeginVertical(); { GUILayout.FlexibleSpace(); _currentDefaultLanguage = (SystemLanguage)EditorGUILayout.EnumPopup(_currentDefaultLanguage); GUILayout.FlexibleSpace(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); if (!_currentDefaultLanguage.Equals(SystemLanguage.Unknown)) { GUI.color = Color.green; if (GUILayout.Button("Create Localization Workspace", titleStyle)) { CreateWorkspace(); } GUI.color = _defaultColor; } } else { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.5f - 10)); { GUILayout.Label("Add Language", centeredMediumStyle); EditorGUILayout.BeginHorizontal("box"); { _scrollPositionLanguagesAdd = EditorGUILayout.BeginScrollView(_scrollPositionLanguagesAdd, GUILayout.ExpandHeight(true)); { foreach (string langName in Enum.GetNames(typeof(SystemLanguage))) { SystemLanguage currentLang = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), langName); if (currentLang != SystemLanguage.Unknown && !_localizationDatabaseFiles.ContainsKey(currentLang)) { EditorGUILayout.BeginHorizontal("box", GUILayout.ExpandWidth(true)); { EditorGUILayout.LabelField(langName); if (GUILayout.Button("+", GUILayout.Width(50))) { _localizationDatabaseFiles.Add(currentLang, currentLang.ToString() + ".csv"); if (!File.Exists(Localizator.Path.DatabaseRootPath + langName + ".csv")) { SaveLocalizationFile(currentLang.ToString()); } } } EditorGUILayout.EndHorizontal(); } } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); { GUILayout.Label("Options", centeredMediumStyle); EditorGUILayout.BeginVertical("box"); { EditorGUILayout.BeginHorizontal("box"); { EditorGUILayout.LabelField("Change Default Language"); List <string> list = new List <string>(); foreach (KeyValuePair <SystemLanguage, string> value in _localizationDatabaseFiles) { list.Add(value.Key.ToString()); } string[] langs = list.ToArray(); int index = list.IndexOf(DefaultLanguage.ToString()); int selected = EditorGUILayout.Popup(index, langs); if (selected != index) { DefaultLanguage = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), langs[selected]); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal("box"); { EditorGUILayout.LabelField("Language Manager"); if (LanguageManager.Instance == null) { if (GUILayout.Button("Create")) { LanguageManager.CreateInstance(); } } else { if (GUILayout.Button("Select")) { Selection.activeGameObject = LanguageManager.Instance.gameObject; } } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical("box", GUILayout.Height(250)); { GUILayout.Label("Created Languages", centeredMediumStyle); if (GUILayout.Button("Edit Root File", GUILayout.ExpandWidth(true), GUILayout.Height(30))) { EditorWindow.GetWindow <CustomEditorWindow_Localizator_EditRoot>(typeof(CustomEditorWindow_Localizator)); } _scrollPositionLanguagesEdit = EditorGUILayout.BeginScrollView(_scrollPositionLanguagesEdit); { foreach (KeyValuePair <SystemLanguage, string> value in _localizationDatabaseFiles) { EditorGUILayout.BeginHorizontal("box", GUILayout.Height(30)); { GUILayout.Space(10); GUILayout.Label(value.Key.ToString(), leftMiddleStyle, GUILayout.Width(150), GUILayout.ExpandHeight(true)); GUILayout.FlexibleSpace(); if (GUILayout.Button("Translate", GUILayout.ExpandWidth(true), GUILayout.MaxWidth(150), GUILayout.ExpandHeight(true))) { CustomEditorWindow_Localizator_EditLang.OpenWindow(value.Key.ToString()); } if (GUILayout.Button("Export", GUILayout.ExpandWidth(true), GUILayout.MaxWidth(150), GUILayout.ExpandHeight(true))) { CustomEditorWindow_Localizator_EditLang.Export(value.Key.ToString()); } if (GUILayout.Button("Update", GUILayout.ExpandWidth(true), GUILayout.MaxWidth(150), GUILayout.ExpandHeight(true))) { CustomEditorWindow_Localizator_EditLang.Update(value.Key.ToString()); } if (GUILayout.Button("Backup", GUILayout.ExpandWidth(true), GUILayout.MaxWidth(150), GUILayout.ExpandHeight(true))) { CustomEditorWindow_Localizator_EditLang.Backup(value.Key.ToString()); } GUI.color = value.Key.Equals(DefaultLanguage) ? Color.gray : Color.red; if (GUILayout.Button("Delete", GUILayout.ExpandWidth(true), GUILayout.MaxWidth(150), GUILayout.ExpandHeight(true)) && !value.Key.Equals(DefaultLanguage)) { languageToRemove.Add(value.Key); } GUI.color = _defaultColor; } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); for (int i = 0; i < languageToRemove.Count; ++i) { DeleteLocalizationFile(languageToRemove[i]); } } }