Ejemplo n.º 1
0
        /// <summary>
        /// StringTableを読み込み、言語ファイルを返す。
        /// 言語ファイルにファイル履歴の枠組みを作成し設定する。
        /// </summary>
        /// <param name="path">StringTableファイルのパス</param>
        /// <param name="productLine">製品区分</param>
        /// <param name="fileID">FileID</param>
        /// <returns>言語ファイル</returns>
        public static MieLanguageFile LoadFromXml(string path, MieProduct.NProductLine productLine, out string fileID)
        {
            //// StringTableの読み込み
            var stringTableFile = StringTableFile.Load(path);
            //// ファイル履歴の作成
            MieLanguageHistoryFile mieLanguageHistoryFile = new MieLanguageHistoryFile(stringTableFile.Name);

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

            var mieLanguageFile = new MieLanguageFile(fileCode);

            stringTableFile
            .Entries
            .ForEach(entry =>
            {
                var referenceID      = MieTranslationLib.MieUtils.MieHashTools.ComputeReferenceID(stringTableFile.Name, entry.ID);
                var mieLanguageEntry = new MieLanguageEntry(entry.ID, entry.DefaultText, entry.FemaleText, productLine, referenceID);
                mieLanguageFile.AddEntry(mieLanguageEntry);
            });

            return(mieLanguageFile);
        }
        /// <summary>
        /// 言語DBの初期化とDB化。
        /// </summary>
        /// <param name="systemDb">データベース接続情報</param>
        /// <param name="langPath">言語情報フォルダーのパス</param>
        /// <param name="productLine">製品区分</param>
        /// <param name="languageType">言語区分</param>
        /// <param name="fileList">FileList</param>
        public void ConvertLanguage(MieSystemDB systemDb, string langPath, MieProduct.NProductLine productLine, MieProduct.NLanguageType languageType, MieFileList fileList)
        {
            if (!Directory.Exists(langPath))
            {
                var msg = $"Directory not found({langPath}).";
                if (productLine == MieProduct.NProductLine.Vanilla)
                {
                    logger.Error(msg);
                    throw new DirectoryNotFoundException(msg);
                }
                else
                {
                    logger.Warn(msg);
                    Console.WriteLine(msg);

                    return;
                }
            }

            //// 話者情報の読み込みとFileListの作成。
            var langInfo = MieStringTableDao.LoadFromFolder(langPath, productLine, languageType, fileList);

            if (this.LanguageInfo == null)
            {
                this.LanguageInfo = langInfo;
            }
            else
            {
                foreach (var langFile in langInfo.Items.Values)
                {
                    this.LanguageInfo.AddFile(langFile, true);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 言語区分をテキスト化したものを返す。
        /// </summary>
        /// <returns>テキスト化した言語区分</returns>
        private MieProduct.NProductLine GetLanguageTypeText()
        {
            MieProduct.NProductLine nProductLine = MieProduct.NProductLine.Vanilla;

            foreach (var entry in this.items.Values)
            {
                if (entry.ProductLine.HasFlag(MieProduct.NProductLine.None))
                {
                    nProductLine |= MieProduct.NProductLine.None;
                }

                if (entry.ProductLine.HasFlag(MieProduct.NProductLine.Vanilla))
                {
                    nProductLine |= MieProduct.NProductLine.Vanilla;
                }

                if (entry.ProductLine.HasFlag(MieProduct.NProductLine.DLC1))
                {
                    nProductLine |= MieProduct.NProductLine.DLC1;
                }

                if (entry.ProductLine.HasFlag(MieProduct.NProductLine.DLC2))
                {
                    nProductLine |= MieProduct.NProductLine.DLC2;
                }

                if (entry.ProductLine.HasFlag(MieProduct.NProductLine.DLC3))
                {
                    nProductLine |= MieProduct.NProductLine.DLC3;
                }
            }

            return(nProductLine);
        }
Ejemplo n.º 4
0
        public static void LoadFromSystemDB(MieSystemDB systemDB, MieLanguageInfo langInfo)
        {
            SQLiteCommand command = systemDB.Connection.CreateCommand();

            command.CommandText = @"SELECT * FROM LanguageEntries ORDER BY FileCode;";
            using (SQLiteDataReader reader = command.ExecuteReader())
            {
                while (reader.Read() == true)
                {
                    var fileCode     = (long)reader["FileCode"];
                    var id           = (int)(long)reader["ID"];
                    var referenceID  = (long)reader["ReferenceID"];
                    var defaultText  = (string)reader["DefaultText"];
                    var femaleText   = (string)reader["FemaleText"];
                    var xProductLine = (long)reader["ProductLine"];
                    var xUpdatedAt   = (long)reader["UpdatedAt"];

                    MieProduct.NProductLine productLine = (MieProduct.NProductLine)Enum.ToObject(typeof(MieProduct.NProductLine), xProductLine);
                    DateTime updateAt = new DateTime(xUpdatedAt);

                    MieLanguageEntry langEntry = new MieLanguageEntry(id, defaultText, femaleText, productLine, referenceID, updateAt);
                    langInfo.AddFileEntry(fileCode, langEntry);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 指定した製品区分の言語エントリー数を返す。
        /// </summary>
        /// <param name="nProductLine">製品区分</param>
        /// <param name="nLanguageType">言語区分</param>
        /// <returns>言語エントリー数</returns>
        public int GetEntryCount(MieProduct.NProductLine nProductLine, MieProduct.NLanguageType nLanguageType)
        {
            var count = this.Items
                        .SelectMany((x) => x.Value.Items)
                        .Count((x) => x.ProductLine.HasFlag(nProductLine));

            return(count);
        }
Ejemplo n.º 6
0
 public void LoadFromFolder(
     string folderPath,
     MieProduct.NProductLine productLine,
     MieProduct.NLanguageType languageType,
     MieFileList fileList)
 {
     this.languageInfo = MieStringTableDao.LoadFromFolder(
         folderPath,
         productLine,
         languageType,
         fileList);
     Console.WriteLine(this.languageInfo.FileCount);
 }
Ejemplo n.º 7
0
        public int GetEntryCount(MieProduct.NProductLine productLine, MieProduct.NLanguageType languageType, bool ommitEmpty)
        {
            var total = 0;

            this.Items.Values
            .ToList()
            .ForEach(x =>
            {
                total += x.GetEntryCount(productLine, languageType, ommitEmpty);
            });

            return(total);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 指定した製品区分のファイル数を返す。
        /// </summary>
        /// <param name="nProductLine">製品区分</param>
        /// <param name="nLanguageType">言語区分</param>
        /// <returns>ファイル数</returns>
        public int GetFileCount(MieProduct.NProductLine nProductLine, MieProduct.NLanguageType nLanguageType)
        {
            int fileCount = 0;

            foreach (var file in this.Items.Values)
            {
                if (file.GetEntryCount(nProductLine, nLanguageType) > 0)
                {
                    fileCount++;
                }
            }

            return(fileCount);
        }
Ejemplo n.º 9
0
 public IDictionary <long, MieLanguageFile> GetFiles(MieProduct.NProductLine productLine)
 {
     if (productLine == MieProduct.NProductLine.ALL)
     {
         return(this.Items);
     }
     else
     {
         var result = this.Items.Values
                      .Where(x => (x.ProductLine & productLine) == productLine)
                      .ToDictionary(x => x.FileCode);
         return(result);
     }
 }
Ejemplo n.º 10
0
        public MieLanguageEntry(int id, string defaultText, string femaleText, MieProduct.NProductLine productLine, long referenceID, DateTime updateDateTime)
        {
            this.ID          = id;
            this.DefaultText = defaultText;
            this.FemaleText  = femaleText;
            this.ProductLine = productLine;
            this.UpdatedAt   = updateDateTime;
            if (string.IsNullOrEmpty(this.FemaleText))
            {
                this.HasFemale = false;
            }
            else
            {
                this.HasFemale = true;
            }

            this.ReferenceID = referenceID;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 指定した製品区分の言語エントリー数を返す。
        /// </summary>
        /// <param name="nProductLine">製品区分</param>
        /// <param name="nLanguageType">言語区分</param>
        /// <param name="ommitEmpty">空文をスキップする</param>
        /// <returns>言語エントリー数</returns>
        public int GetEntryCount(MieProduct.NProductLine nProductLine, MieProduct.NLanguageType nLanguageType, bool ommitEmpty = false)
        {
            var total = 0;

            if (ommitEmpty)
            {
                total = this.items.Values.Count(
                    (x) => (
                        x.ProductLine.HasFlag(nProductLine) &&
                        !string.IsNullOrWhiteSpace(x.DefaultText)));
            }
            else
            {
                total = this.items.Values.Count(
                    (x) => x.ProductLine.HasFlag(nProductLine));
            }

            return(total);
        }
Ejemplo n.º 12
0
        public static MieLanguageInfo LoadFromFolder(
            string folderPath,
            MieProduct.NProductLine productLine,
            MieProduct.NLanguageType languageType,
            MieFileList fileList)
        {
            var mieLanguageInfo = new MieLanguageInfo();

            string[] files = Directory.GetFiles(folderPath, "*.stringtable", SearchOption.AllDirectories);
            files
            .Where(file => Path.GetExtension(file).ToLower() == ".stringtable")
            .ToList()
            .ForEach(x =>
            {
                var fileID       = string.Empty;
                var languageFile = LoadFromXml(x, productLine, out fileID);
                //// 言語情報の登録
                mieLanguageInfo.AddFile(languageFile, false);
                //// FileListの作成
                fileList.AddEntryByFileIdAndFileCode(fileID, languageFile.FileCode, languageType);
            });

            return(mieLanguageInfo);
        }
Ejemplo n.º 13
0
        public static void MargeFromFolder(MieLanguageInfo mieLanguageInfo, string folderPath, MieProduct.NProductLine productLine, MieProduct.NLanguageType languageType)
        {
            if (!Directory.Exists(folderPath))
            {
                var msg = $"Warning: Folder not exists. Folder({folderPath})";
                logger.Warn(msg);
                Console.WriteLine(msg);
                return;
            }

            string[] files = Directory.GetFiles(folderPath, "*.stringtable", SearchOption.AllDirectories);
            files
            .Where(file => Path.GetExtension(file).ToLower() == ".stringtable")
            .ToList()
            .ForEach(x =>
            {
                var fileID       = string.Empty;
                var languageFile = LoadFromXml(x, productLine, out fileID);
                mieLanguageInfo.AddFile(languageFile, true);
            });
        }
Ejemplo n.º 14
0
 public MieLanguageEntry(int id, string defaultText, string femaleText, MieProduct.NProductLine productLine, long referenceID)
     : this(id, defaultText, femaleText, productLine, referenceID, DateTime.UtcNow)
 {
 }