void ExportToXLS(string chosenExportFolder) { string name = chosenCulture.englishName + " - " + chosenCulture.languageCode + xlsFileEnding; XLSExporter.Write(chosenExportFolder + "/" + name, chosenCulture.englishName, LanguageHandlerEditor.LoadLanguageFile(chosenCulture.languageCode, false)); }
/// <summary> /// Creates a new language /// </summary> /// <param name="languageName">The language code of the language to create</param> /// <param name="fromFile">Base language values to create a language from where each list of strings is a row.</param> public static void CreateNewLanguage(string languageName, List <List <string> > fromFile = null) { Dictionary <string, string> rootValues = LanguageHandlerEditor.LoadLanguageFile(null, true); //Copy the keys over to the new language Dictionary <string, string> baseDictionary = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> keyPair in rootValues) { baseDictionary.Add(keyPair.Key, ""); } if (fromFile != null) { foreach (var row in fromFile) { if (row.Count != 2) { Debug.LogError("Файл CSV не в правильном формате."); break; } baseDictionary[row[0]] = row[1]; } } //Save the new language file SaveLanguageFile(baseDictionary, LocalizationWorkspace.LanguageFilePath(languageName)); }
void ShowExportGUI() { if (GUILayout.Button("Экспорт")) { string folderPath = EditorUtility.OpenFolderPanel("Выберите папку для сохранения.", "", ""); if (availableFileFormats[chosenFileFormat] == csvFileEnding) { string fullPath = folderPath + "/" + exportFileName + csvFileEnding; CSVParser.Write(fullPath, CSVParser.GetDelimiter(delimiter), new List <string>(LanguageHandlerEditor.LoadLanguageFile(null, true).Keys), LanguageHandlerEditor.LoadAllLanguageFiles()); Debug.Log("Экспортирован файл CSV в " + fullPath); this.Close(); } else if (availableFileFormats[chosenFileFormat] == xlsFileEnding) { string fullPath = folderPath + "/" + exportFileName + xlsFileEnding; XLSExporter.Write(fullPath, "Languages", new List <string>(LanguageHandlerEditor.LoadLanguageFile(null, true).Keys), LanguageHandlerEditor.LoadAllLanguageFiles()); Debug.Log("Экспортирован файл XLS в " + fullPath); this.Close(); } else { Debug.LogError("BulkUpdateWindow: Неподдерживаемый формат экспорта!"); } } }
public static void UpdateLanguageFile(string languageCode, List <List <string> > values) { Dictionary <string, string> languageItems = null; if (FileUtility.Exists(LocalizationWorkspace.LanguageFilePath(languageCode))) { languageItems = LanguageHandlerEditor.LoadLanguageFile(languageCode, false); } else { languageItems = new Dictionary <string, string>(); } int updatedKeys = 0; foreach (List <string> row in values) { if (row.Count != 2) { continue; } string key = row[0].TrimStart('\r', '\n').TrimEnd('\r', '\n').Trim(); string value = row[1]; if (!languageItems.ContainsKey(key)) { continue; } languageItems[key] = value; updatedKeys++; } LanguageHandlerEditor.SaveLanguageFile(languageItems, LocalizationWorkspace.LanguageFilePath(languageCode)); Debug.Log("Обновленный язык:" + languageCode + ", Ключ обновлен:" + updatedKeys); }