Skip to content

feat(synced-lyrics): thai romanization #3618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hax0r31337
Copy link

@hax0r31337 hax0r31337 commented Jul 13, 2025

Support of Thai romanization from @dehoist/romanize-thai

image

@ArjixWasTaken
Copy link
Contributor

i also suggest to expand the language detection to entire lyrics instead of a single line
as the language detection are mistaking japanese sentence with no kana to mandarin

that is a really hard problem to solve, since there are songs that mix japanese/korean/chinese

@hax0r31337
Copy link
Author

i also suggest to expand the language detection to entire lyrics instead of a single line
as the language detection are mistaking japanese sentence with no kana to mandarin

that is a really hard problem to solve, since there are songs that mix japanese/korean/chinese

well, I never thought there are cases like that

@JellyBrick JellyBrick added enhancement New feature or request dependencies Pull requests that update a dependency file and removed dependencies Pull requests that update a dependency file labels Jul 19, 2025
@JellyBrick JellyBrick requested a review from Copilot July 22, 2025 13:21
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Thai language romanization support to the synced lyrics plugin by integrating the @dehoist/romanize-thai library. The implementation includes Thai text detection, word segmentation using the Intl.Segmenter API, and fallback handling.

  • Adds Thai romanization functionality with intelligent word segmentation
  • Refactors the romanization logic to use a cleaner handler-based approach
  • Integrates the @dehoist/romanize-thai external dependency

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/plugins/synced-lyrics/renderer/utils.tsx Implements Thai romanization function and refactors existing romanization logic
package.json Adds the @dehoist/romanize-thai dependency
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment on lines +188 to +194
.map((segment) => segment.isWordLike ? romanizeThaiFrag(segment.segment) : segment.segment.trim())
.join(' ')
.trim();

return latin;
};

Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The ternary operation could be more readable by extracting the logic into a separate function or using explicit if-else blocks for better clarity.

Suggested change
.map((segment) => segment.isWordLike ? romanizeThaiFrag(segment.segment) : segment.segment.trim())
.join(' ')
.trim();
return latin;
};
.map(processThaiSegment)
.join(' ')
.trim();
return latin;
};
const processThaiSegment = (segment: { isWordLike: boolean; segment: string }): string => {
return segment.isWordLike ? romanizeThaiFrag(segment.segment) : segment.segment.trim();
};

Copilot uses AI. Check for mistakes.


const segments = Array.from(thaiSegmenter.segment(line));
const latin = segments
.map((segment) => segment.isWordLike ? romanizeThaiFrag(segment.segment) : segment.segment.trim())
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider why .trim() is only applied to non-word segments. This asymmetry might lead to inconsistent spacing behavior and should be documented or applied consistently.

Suggested change
.map((segment) => segment.isWordLike ? romanizeThaiFrag(segment.segment) : segment.segment.trim())
.map((segment) => romanizeThaiFrag(segment.segment).trim())

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'cause word's can't have spaces in them, dumb AI

@ArjixWasTaken
Copy link
Contributor

i also suggest to expand the language detection to entire lyrics instead of a single line
as the language detection are mistaking japanese sentence with no kana to mandarin

that is a really hard problem to solve, since there are songs that mix japanese/korean/chinese

well, I never thought there are cases like that

One solution might be to detect what percentage of the lyrics is japanese, if it's above a threshold of like 95%, then we assume all chinese characters are actually kanji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants