Example #1
0
        /// <summary>
        /// 言語情報をCSV形式で保存する。
        /// </summary>
        /// <param name="path">CSVファイルのパス</param>
        /// <param name="langInfo">言語情報</param>
        /// <param name="languageNo">言語番号</param>
        public static void SaveToCsv(
            string path, FssLanguageInfo langInfo, FssLanguageInfo.LanguageNo languageNo)
        {
            var enc = new UTF8Encoding(false);

            //// フォルダーが存在しない場合は作成する。
            var sheetFolder = Path.GetDirectoryName(path);

            FssFileUtils.SafeCreateDirectory(sheetFolder);

            using (var writer = new CsvWriter(new StreamWriter(path, false, enc)))
            {
                writer.Configuration.RegisterClassMap <CsvMapper>();
                writer.WriteHeader <FssTransSheetEntry>();
                writer.NextRecord();

                var data = new FssTransSheetEntry();
                int no   = 0;
                foreach (var entry in langInfo.LanguageFile.Items.Values)
                {
                    data.EntryID  = entry.EntryID;
                    data.Hint     = entry.Description;
                    data.LangEN   = entry.Texts[(int)languageNo];
                    data.Sequence = no;

                    writer.WriteRecord(data);
                    writer.NextRecord();

                    no++;
                }
            }
        }
Example #2
0
        public static FssLanguageInfo Translate(
            FssLanguageInfo langageInfoEn, FssTransSheetFile sheetFile, bool useMT, FssLanguageInfo.LanguageNo languageNo)
        {
            var langageInfoJp = new FssLanguageInfo();

            langageInfoJp.SetFile(new FssLanguageFile());

            langageInfoJp.SetHeader(langageInfoEn.LanguageHeader.Clone());

            foreach (var langEntryEn in langageInfoEn.LanguageFile.Items.Values)
            {
                var langEntryJp = langEntryEn.Clone();

                string translatedText = sheetFile.Translate(
                    langEntryEn.EntryID, langEntryEn.Texts[(int)languageNo], useMT);
                langEntryJp.Texts[(int)languageNo] = translatedText;

                langageInfoJp.LanguageFile.AddEntry(langEntryJp);
            }

            langageInfoJp.SetFooter(langageInfoEn.LanguageFooter.Clone());

            return(langageInfoJp);
        }