[bugfix] UI: Transliteration: Fix the bug that isn't shown when only hiragana or only hepburn is provided.

This commit is contained in:
Sakamoto Shiina
2025-09-30 04:55:23 +09:00
parent e32e5c1b5f
commit 957cddfe18

View File

@@ -94,6 +94,7 @@ const MessageWithTransliteration = ({ item }) => {
const hira = token.hira ?? ""; const hira = token.hira ?? "";
const hepburn = token.hepburn ?? ""; const hepburn = token.hepburn ?? "";
// Only hovered romaji if it exists. (No ruby cuz 'orig' and 'hira' are same.)
if (hira && hira === orig && hepburn) { if (hira && hira === orig && hepburn) {
return ( return (
<span key={key} title={hepburn} className={styles.with_hepburn}> <span key={key} title={hepburn} className={styles.with_hepburn}>
@@ -102,7 +103,8 @@ const MessageWithTransliteration = ({ item }) => {
); );
} }
if (hira && hira !== orig && hepburn) { // Ruby hiragana and hovered romaji.
if (hira && hepburn) {
return ( return (
<ruby key={key} title={hepburn} className={styles.with_hepburn}> <ruby key={key} title={hepburn} className={styles.with_hepburn}>
{orig} {orig}
@@ -111,15 +113,20 @@ const MessageWithTransliteration = ({ item }) => {
); );
} }
if (hepburn && hepburn !== orig) { // Ruby romaji or hiragana.
return ( if (hepburn || hira) {
<ruby key={key} className={styles.ruby}> const ruby = hepburn ? hepburn : hira;
{orig} if (ruby !== orig) {
<rt>{hepburn}</rt> return (
</ruby> <ruby key={key} className={styles.ruby}>
); {orig}
<rt>{ruby}</rt>
</ruby>
);
};
} }
// Nothing. Original only.
return ( return (
<span key={key} className={styles.original_only}> <span key={key} className={styles.original_only}>
{orig} {orig}