private int ImportExcelFileAndCreateTags(Languages excelSelectedLanguage, int categoryIndex, int tagNameIndex, int contentIndex) { LanguageFile newFile = new LanguageFile(m_englishFile, excelSelectedLanguage); List <LanguageFileEntry> excelEntries = ExcelManager.ImportExcelFileEntries(excelPath, categoryIndex, tagNameIndex, contentIndex); if (excelIgnoreHeaderLine) { excelEntries.RemoveAt(0); } //neue keys hinzufügen foreach (LanguageFileEntry entry in excelEntries) { if (!m_newTagList.Contains(entry.textTag)) { m_newTagList.Add(entry.textTag); } //Im EnglishFile nur Key hinzufügen, wenn noch nicht da m_englishFile.SetEntry(entry.textTag); newFile.SetEntry(entry.textTag, entry); } //neues file schreiben LocalizationManager.WriteNewLanguageFile(excelSelectedLanguage, newFile); //neues File reloaden, wenn ausgewählt if (m_loadedLanguage == excelSelectedLanguage) { m_secondLanguageFile = LocalizationManager.GetLanguageDataFromFile(excelSelectedLanguage); } return(excelEntries.Count); }
public void GenerateLanguageFile() { LanguageFile languagesFile = new LanguageFile(); fileKeys.ForEach(key => { languagesFile.SetEntry(key); }); string filePath = Application.dataPath + DirectoryPath + "LanguageXX.lang"; File.WriteAllText(filePath, languagesFile.GetJsonFormat()); AssetDatabase.Refresh(); }
public static void WriteNewKeysToLanguageFile(Languages language, List <string> keys, List <string> content = null) { string filePath = Application.dataPath + DirectoryPath + language.ToString() + ".lang"; LanguageFile languagesFile = new LanguageFile(); if (File.Exists(filePath)) { languagesFile = JsonUtility.FromJson <LanguageFile>(File.ReadAllText(filePath)); } for (int i = 0; i < keys.Count; i++) { if (content != null) { languagesFile.SetEntry(keys[i], new LanguageFileEntry(keys[i], content[i])); } else { languagesFile.SetEntry(keys[i]); } } File.WriteAllText(filePath, languagesFile.GetJsonFormat()); }
private void DrawLanguageContent() { if (m_canRemoveTagsFromDict) { m_deleteTagList.ForEach(tag => { if (m_categorysAndTagsList.ContainsKey(GetUntilOrEmpty(tag))) { if (m_categorysAndTagsList[GetUntilOrEmpty(tag)].Count == 1) { m_categorysAndTagsList.Remove(GetUntilOrEmpty(tag)); } else { m_categorysAndTagsList[GetUntilOrEmpty(tag)].Remove(tag); } } }); m_canRemoveTagsFromDict = false; m_selectedIndexCategoryForTags = 0; } if (m_categorysAndTagsList.Count == 0) { return; } m_selectedIndexCategoryForTags = EditorGUILayout.Popup("Category", m_selectedIndexCategoryForTags, m_categorysAndTagsList.Keys.ToArray(), GUILayout.Width(TAG_HEADER_TAG_WIDTH - 20)); if (m_selectedIndexCategoryForTags >= m_categorysAndTagsList.Count) { m_selectedIndexCategoryForTags = 0; } if (m_categorysAndTagsList.Count == 0) { return; } EditorGUI.indentLevel++; float contentTextSize = Mathf.Clamp(((position.width - TAG_HEADER_TAG_WIDTH) / 2), 100f, 9999f); m_categorysAndTagsList.ElementAt(m_selectedIndexCategoryForTags).Value.ForEach(tag => { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.MaxWidth(20))) { m_deleteTagList.Add(tag); m_newTagList.Remove(tag); m_englishFile.RemoveEntry(tag); m_canRemoveTagsFromDict = true; isDirtyTags = true; return; } if (!m_canRemoveTagsFromDict && m_englishFile.Exists(tag)) { EditorGUILayout.SelectableLabel(tag, GUILayout.Height(15), GUILayout.Width(TAG_HEADER_TAG_WIDTH - 50)); LanguageFileEntry englishEntry = m_englishFile.GetEntry(tag); string areaText = EditorGUILayout.TextArea(m_englishFile.GetEntryText(tag), GUILayout.Width(contentTextSize)); if (!englishEntry.textContent.Equals(areaText)) { isDirtyEng = true; } englishEntry.textContent = areaText; m_englishFile.SetEntry(tag, englishEntry); if (m_secondLanguageFile.fileLanguage != Languages.English && m_secondLanguageFile.Exists(tag)) { LanguageFileEntry secondEntry = m_secondLanguageFile.GetEntry(tag); string areaText2 = EditorGUILayout.TextArea(m_secondLanguageFile.GetEntryText(tag), GUILayout.Width(contentTextSize)); if (!secondEntry.textContent.Equals(areaText2)) { isDirtySecond = true; } secondEntry.textContent = areaText2; m_secondLanguageFile.SetEntry(tag, secondEntry); } } EditorGUILayout.EndHorizontal(); }); EditorGUI.indentLevel--; }