feat: Provide the 'isOnlyOutputTranslation option to output only translated lyrics.

This commit is contained in:
real-zony
2022-09-22 15:48:20 +08:00
parent be4380c744
commit 8385f6f118
4 changed files with 29 additions and 5 deletions

View File

@@ -36,4 +36,9 @@ public class LyricConfigOption
/// 歌词文件的编码格式。
/// </summary>
public string FileEncoding { get; set; } = "utf-8";
/// <summary>
/// 是否只输出翻译歌词。
/// </summary>
public bool IsOnlyOutputTranslation { get; set; } = false;
}

View File

@@ -43,6 +43,11 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
if (_options.Provider.Lyric.Config.IsEnableTranslation && !string.IsNullOrEmpty(translationLyric))
{
var translatedLyric = InternalBuildLyricObject(new LyricItemCollection(_options.Provider.Lyric.Config), translationLyric);
if (_options.Provider.Lyric.Config.IsOnlyOutputTranslation)
{
return translatedLyric;
}
return lyric + translatedLyric;
}

View File

@@ -41,8 +41,9 @@ globalOption:
priority: 3
# 歌词下载的一些共有配置参数。
config:
isOneLine: true # 双语歌词是否合并为一行展示。
lineBreak: "\n" # 换行符的类型,记得使用双引号指定。
isEnableTranslation: true # 是否启用翻译歌词。
isSkipExistLyricFiles: false # 如果歌词文件已经存在,是否跳过这些文件
fileEncoding: 'utf-8' # 歌词文件的编码格式
isOneLine: true # 双语歌词是否合并为一行展示。
lineBreak: "\n" # 换行符的类型,记得使用双引号指定。
isEnableTranslation: true # 是否启用翻译歌词。
isOnlyOutputTranslation: false # 是否只输出翻译歌词
isSkipExistLyricFiles: false # 如果歌词文件已经存在,是否跳过这些文件
fileEncoding: 'utf-8' # 歌词文件的编码格式。