예제 #1
0
        public static void SaveToXml(
            string fileID,
            StringTableFile stringTableFile,
            string jpFolderPath,
            bool useReferenceID = false)
        {
            var path   = Path.Combine(jpFolderPath, fileID + ".stringtable");
            var folder = Path.GetDirectoryName(path);

            MieCommonUtils.SafeCreateDirectory(folder);

            StringTableFile.Save(stringTableFile, path, StringTableFile.ExportType.Xml);
        }
예제 #2
0
        /// <summary>
        /// Tests the save method using the specified file path.
        /// </summary>
        private void TestSaveMethod(string filePath)
        {
            StringTableFile stringTableFile = new StringTableFile();

            stringTableFile.Load(filePath);

            MemoryStream savedStream = new MemoryStream();

            stringTableFile.Save(savedStream);
            savedStream.Seek(0, SeekOrigin.Begin);

            StringTableFile savedStringTableFile = new StringTableFile();

            savedStringTableFile.Load(savedStream);
            savedStream.Close();

            Assert.AreEqual(stringTableFile.TableType, stringTableFile.TableType, "Table types do not match");
            Assert.AreEqual(stringTableFile.RowCount, stringTableFile.RowCount, "Row counts do not match");

            for (int i = 0; i < stringTableFile.RowCount; i++)
            {
                for (int j = 0; j < stringTableFile.LanguageCount; j++)
                {
                    StringTableLanguage language = (StringTableLanguage)j;

                    Assert.AreEqual(stringTableFile[i].GetText(language), savedStringTableFile[i].GetText(language), "Text values do not match");

                    if (stringTableFile.TableType == StringTableType.Item || stringTableFile.TableType == StringTableType.Quest)
                    {
                        Assert.AreEqual(stringTableFile[i].GetDescription(language), savedStringTableFile[i].GetDescription(language), "Description values do not match");

                        if (stringTableFile.TableType == StringTableType.Quest)
                        {
                            Assert.AreEqual(stringTableFile[i].GetStartMessage(language), savedStringTableFile[i].GetStartMessage(language), "Start message values do not match");
                            Assert.AreEqual(stringTableFile[i].GetEndMessage(language), savedStringTableFile[i].GetEndMessage(language), "End message values do not match");
                        }
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 日本語化とXMLファイルの保存。
        /// </summary>
        /// <param name="fileID">FileID</param>
        /// <param name="enFolderPath">原文のXMLファイルのパス</param>
        /// <param name="jpFolderPath">日本語版のXMLファイルのパス</param>
        /// <param name="transSheetFile">翻訳シートファイル</param>
        /// <param name="useReferenceID">ReferenceIDの有無</param>
        public static void SaveToXml(
            string fileID,
            string enFolderPath,
            string jpFolderPath,
            MieTransSheetFile transSheetFile,
            bool useReferenceID = false)
        {
            //// StringTableの読み込み
            var enPath = Path.Combine(enFolderPath, fileID + ".stringtable");
            {
                //// Bugfix: stringtable内のNameパラメーターに誤りがあるため、修正する。
                enPath = enPath.Replace("bounty encounters", "bounty_encounters");
            }

            var stringTableFile = StringTableFile.Load(enPath);
            //// ファイル履歴の作成
            MieLanguageHistoryFile mieLanguageHistoryFile = new MieLanguageHistoryFile(stringTableFile.Name);

            //// FileIDを統一形式に変換する。
            var commonFileID = MieStringUtils.NormalizedFileID(fileID);
            var fileCode     = MieHashTools.ComputeFileID(commonFileID);

            if (transSheetFile == null)
            {
                //// 翻訳シートがない場合は転記しない。
            }
            else
            {
                foreach (var entry in stringTableFile.Entries)
                {
                    MieTransSheetEntry sheetEntry = transSheetFile.GetEntry(entry.ID);

                    if (sheetEntry == null || string.IsNullOrWhiteSpace(entry.DefaultText))
                    {
                        //// 原文の翻訳テキストが存在しない場合は転記しない。
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(sheetEntry.DefaultTranslationText))
                        {
                            //// 翻訳テキストが存在しない場合は転記しない。
                        }
                        else
                        {
                            entry.DefaultText = sheetEntry.DefaultTranslationText;
                            if (!string.IsNullOrWhiteSpace(entry.FemaleText))
                            {
                                //// 女性版テキストが存在する場合は標準テキストを転記する。
                                entry.FemaleText = sheetEntry.DefaultTranslationText;
                            }
                        }
                    }

                    if (sheetEntry != null)
                    {
                        if (sheetEntry.FileID.StartsWith(@"game"))
                        {
                            if (useReferenceID)
                            {
                                entry.DefaultText = $"{sheetEntry.ReferenceID}:{entry.DefaultText}";
                            }
                        }
                    }
                }
            }

            var jpPath   = Path.Combine(jpFolderPath, fileID + ".stringtable");
            var jpFolder = Path.GetDirectoryName(jpPath);

            MieCommonUtils.SafeCreateDirectory(jpFolder);
            StringTableFile.Save(stringTableFile, jpPath, StringTableFile.ExportType.Xml);
        }