コード例 #1
0
        void ExportToXLS(string chosenExportFolder)
        {
            string name = chosenCulture.englishName + " - " + chosenCulture.languageCode + xlsFileEnding;

            XLSExporter.Write(chosenExportFolder + "/" + name, chosenCulture.englishName,
                              LanguageHandlerEditor.LoadLanguageFile(chosenCulture.languageCode, false));
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
ファイル: BulkUpdateWindow.cs プロジェクト: error911/GGTeam
        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: Неподдерживаемый формат экспорта!");
                }
            }
        }
コード例 #4
0
        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);
        }