mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 02:44:56 +08:00
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using BetterLyrics.Core.Interfaces;
|
|
using RomajiConverter.Core.Helpers;
|
|
using System.Reflection;
|
|
|
|
namespace BetterLyrics.Plugins.Romaji
|
|
{
|
|
public class RomajiPlugin : ILyricsTransliterationPlugin
|
|
{
|
|
public string Id => "jayfunc.romaji";
|
|
|
|
public string Name => "Romaji";
|
|
|
|
public string Description => "Convert Japanese lyrics to Romaji transliteration.";
|
|
|
|
public string Author => "jayfunc";
|
|
|
|
public void Initialize()
|
|
{
|
|
string? pluginPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
RomajiHelper.Init(pluginPath);
|
|
}
|
|
|
|
public Task<string?> GetTransliterationAsync(string text, string targetLangCode)
|
|
{
|
|
string? result = null;
|
|
if (targetLangCode == "ja-latin")
|
|
{
|
|
var lines = RomajiHelper.ToRomaji(text);
|
|
result = string.Join("\n", lines.Select(p => string.Join(" ", p.Units.Select(q => q.Romaji))));
|
|
}
|
|
return Task.FromResult(result);
|
|
}
|
|
}
|
|
}
|