【调整】调整本土化相关选项名,统一为 --{l10n}:{option}

main
walon 2021-11-29 10:17:48 +08:00
parent e9244a30da
commit 1de0299b17
4 changed files with 33 additions and 28 deletions

View File

@ -41,22 +41,22 @@ namespace Luban.Job.Cfg
[Option("export_exclude_tags", Required = false, HelpText = "export exclude tags. default export all tags")] [Option("export_exclude_tags", Required = false, HelpText = "export exclude tags. default export all tags")]
public string ExportExcludeTags { get; set; } = ""; public string ExportExcludeTags { get; set; } = "";
[Option('t', "l10n_timezone", Required = false, HelpText = "timezone")] [Option("l10n:timezone", Required = false, HelpText = "timezone")]
public string TimeZone { get; set; } public string L10nTimeZone { get; set; }
[Option("input_l10n_text_files", Required = false, HelpText = "input l10n text table files. can be multi, sep by ','")] [Option("l10n:input_text_files", Required = false, HelpText = "input l10n text table files. can be multi, sep by ','")]
public string InputTextTableFiles { get; set; } public string L10nInputTextTableFiles { get; set; }
[Option("l10n_text_field_name", Required = false, HelpText = "text value field name of text table files. default is text")] [Option("l10n:text_field_name", Required = false, HelpText = "text value field name of text table files. default is text")]
public string TextValueFieldName { get; set; } public string L10nTextValueFieldName { get; set; }
[Option("output_l10n_not_translated_text_file", Required = false, HelpText = "the file save not translated l10n texts.")] [Option("l10n:output_not_translated_text_file", Required = false, HelpText = "the file save not translated l10n texts.")]
public string OutputNotTranslatedTextFile { get; set; } public string L10nOutputNotTranslatedTextFile { get; set; }
[Option("patch", Required = false, HelpText = "patch name")] [Option("10n:patch", Required = false, HelpText = "patch name")]
public string PatchName { get; set; } public string L10nPatchName { get; set; }
[Option("patch_input_data_dir", Required = false, HelpText = "patch input data root dir")] [Option("10n:patch_input_data_dir", Required = false, HelpText = "patch input data root dir")]
public string PatchInputDataDir { get; set; } public string L10nPatchInputDataDir { get; set; }
} }
} }

View File

@ -76,7 +76,7 @@ namespace Luban.Job.Cfg
return false; return false;
} }
if (string.IsNullOrWhiteSpace(options.InputTextTableFiles) ^ string.IsNullOrWhiteSpace(options.OutputNotTranslatedTextFile)) if (string.IsNullOrWhiteSpace(options.L10nInputTextTableFiles) ^ string.IsNullOrWhiteSpace(options.L10nOutputNotTranslatedTextFile))
{ {
errMsg = "--input_l10n_text_files must be provided with --output_l10n_not_translated_text_file"; errMsg = "--input_l10n_text_files must be provided with --output_l10n_not_translated_text_file";
return false; return false;
@ -88,7 +88,7 @@ namespace Luban.Job.Cfg
} }
} }
if (string.IsNullOrWhiteSpace(options.PatchName) ^ string.IsNullOrWhiteSpace(options.PatchInputDataDir)) if (string.IsNullOrWhiteSpace(options.L10nPatchName) ^ string.IsNullOrWhiteSpace(options.L10nPatchInputDataDir))
{ {
errMsg = "--patch must be provided with --patch_input_data_dir"; errMsg = "--patch must be provided with --patch_input_data_dir";
return false; return false;
@ -142,10 +142,10 @@ namespace Luban.Job.Cfg
var rawDefines = loader.BuildDefines(); var rawDefines = loader.BuildDefines();
TimeZoneInfo timeZoneInfo = string.IsNullOrEmpty(args.TimeZone) ? null : TimeZoneInfo.FindSystemTimeZoneById(args.TimeZone); TimeZoneInfo timeZoneInfo = string.IsNullOrEmpty(args.L10nTimeZone) ? null : TimeZoneInfo.FindSystemTimeZoneById(args.L10nTimeZone);
var excludeTags = args.ExportExcludeTags.Split(',').Select(t => t.Trim().ToLowerInvariant()).Where(t => !string.IsNullOrEmpty(t)).ToList(); var excludeTags = args.ExportExcludeTags.Split(',').Select(t => t.Trim().ToLowerInvariant()).Where(t => !string.IsNullOrEmpty(t)).ToList();
var ass = new DefAssembly(args.PatchName, timeZoneInfo, excludeTags, agent) var ass = new DefAssembly(args.L10nPatchName, timeZoneInfo, excludeTags, agent)
{ {
CsUseUnityVectors = args.CsUseUnityVectors, CsUseUnityVectors = args.CsUseUnityVectors,
OutputCompactJson = args.OutputCompactJson, OutputCompactJson = args.OutputCompactJson,
@ -164,7 +164,7 @@ namespace Luban.Job.Cfg
bool hasLoadCfgData = false; bool hasLoadCfgData = false;
bool needL10NTextConvert = !string.IsNullOrWhiteSpace(args.InputTextTableFiles); bool needL10NTextConvert = !string.IsNullOrWhiteSpace(args.L10nInputTextTableFiles);
async Task CheckLoadCfgDataAsync() async Task CheckLoadCfgDataAsync()
{ {
@ -173,13 +173,13 @@ namespace Luban.Job.Cfg
hasLoadCfgData = true; hasLoadCfgData = true;
var timer = new ProfileTimer(); var timer = new ProfileTimer();
timer.StartPhase("load config data"); timer.StartPhase("load config data");
await DataLoaderUtil.LoadCfgDataAsync(agent, ass, args.InputDataDir, args.PatchName, args.PatchInputDataDir, args.InputConvertDataDir); await DataLoaderUtil.LoadCfgDataAsync(agent, ass, args.InputDataDir, args.L10nPatchName, args.L10nPatchInputDataDir, args.InputConvertDataDir);
timer.EndPhaseAndLog(); timer.EndPhaseAndLog();
if (needL10NTextConvert) if (needL10NTextConvert)
{ {
ass.InitL10n(args.TextValueFieldName); ass.InitL10n(args.L10nTextValueFieldName);
await DataLoaderUtil.LoadTextTablesAsync(agent, ass, ".", args.InputTextTableFiles); await DataLoaderUtil.LoadTextTablesAsync(agent, ass, ".", args.L10nInputTextTableFiles);
} }
timer.StartPhase("validate"); timer.StartPhase("validate");
@ -228,7 +228,7 @@ namespace Luban.Job.Cfg
{ {
var notConvertTextList = DataExporterUtil.GenNotConvertTextList(ass.NotConvertTextSet); var notConvertTextList = DataExporterUtil.GenNotConvertTextList(ass.NotConvertTextSet);
var md5 = FileUtil.CalcMD5(notConvertTextList); var md5 = FileUtil.CalcMD5(notConvertTextList);
string outputNotConvertTextFile = args.OutputNotTranslatedTextFile; string outputNotConvertTextFile = args.L10nOutputNotTranslatedTextFile;
CacheManager.Ins.AddCache(outputNotConvertTextFile, md5, notConvertTextList); CacheManager.Ins.AddCache(outputNotConvertTextFile, md5, notConvertTextList);
genScatteredFiles.Add(new FileInfo() { FilePath = outputNotConvertTextFile, MD5 = md5 }); genScatteredFiles.Add(new FileInfo() { FilePath = outputNotConvertTextFile, MD5 = md5 });

View File

@ -0,0 +1,11 @@
using CommandLine;
using Luban.Job.Common;
namespace Luban.Job.Db
{
class GenArgs : GenArgsBase
{
[Option('g', "gen_type", Required = true, HelpText = "cs,typescript ")]
public string GenType { get; set; }
}
}

View File

@ -17,15 +17,9 @@ using FileInfo = Luban.Common.Protos.FileInfo;
namespace Luban.Job.Db namespace Luban.Job.Db
{ {
public class JobController : IJobController public class JobController : IJobController
{ {
class GenArgs : GenArgsBase
{
[Option('g', "gen_type", Required = true, HelpText = "cs,typescript ")]
public string GenType { get; set; }
}
private bool TryParseArg(List<string> args, out GenArgs options, out string errMsg) private bool TryParseArg(List<string> args, out GenArgs options, out string errMsg)
{ {
var helpWriter = new StringWriter(); var helpWriter = new StringWriter();