fix furigana and romaji issues (#2219)

* fix furigana romaji not displaying

* fix lyrics export crash when generation is enabled
This commit is contained in:
York
2026-07-15 03:08:26 +08:00
committed by GitHub
parent f462ebafdb
commit 552a6104e0
3 changed files with 32 additions and 11 deletions
+18 -2
View File
@@ -35,6 +35,10 @@ const getKuroshiro = async () => {
};
export const convertFurigana = async (text: string): Promise<string> => {
if (typeof text !== 'string' || !text) {
return text;
}
const KuroshiroClass = (Kuroshiro as any).default || Kuroshiro;
// check if the text contains any Japanese kana (to distinguish Japanese from Chinese text, which shares Kanji)
@@ -51,7 +55,11 @@ export const convertFurigana = async (text: string): Promise<string> => {
};
export const convertFuriganaFragment = async (text: string): Promise<string> => {
if (!text || !hasJapanese(text)) {
if (typeof text !== 'string' || !text) {
return text;
}
if (!hasJapanese(text)) {
return text;
}
@@ -65,6 +73,10 @@ export const convertFuriganaFragment = async (text: string): Promise<string> =>
};
export const convertRomaji = async (text: string): Promise<string> => {
if (typeof text !== 'string' || !text) {
return text;
}
const KuroshiroClass = (Kuroshiro as any).default || Kuroshiro;
if (!KuroshiroClass.Util.hasKana(text)) return '';
@@ -79,7 +91,7 @@ export const convertRomaji = async (text: string): Promise<string> => {
};
export const parseLyricsTextTokens = async (text: string): Promise<LyricTextToken[]> => {
if (!text || !hasJapanese(text)) {
if (typeof text !== 'string' || !text || !hasJapanese(text)) {
return [];
}
@@ -108,6 +120,10 @@ export const parseLyricsTextTokens = async (text: string): Promise<LyricTextToke
};
export const convertRomajiTokens = async (text: string): Promise<RomajiToken[]> => {
if (typeof text !== 'string' || !text) {
return [];
}
const KuroshiroClass = (Kuroshiro as any).default || Kuroshiro;
if (!KuroshiroClass.Util.hasKana(text)) {