Skip to content
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

Nora v3.1.0-stable Minor Update #258

Open
wants to merge 120 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
fd2d137
Updated to v3.1.0-stable.20240602
Sandakan Jun 2, 2024
1a8ca83
add support for symbolic links
Brunight Jun 3, 2024
3b9a878
fix misstype
Brunight Jun 6, 2024
6bc7e74
add try catch block so the function doesn't throw with broken symlinks
Brunight Jun 6, 2024
76a4574
Updated to v3.1.0-stable.20240607
Sandakan Jun 7, 2024
ec922e2
Merge pull request #259 from Brunight/minor-release
Sandakan Jun 7, 2024
3747e95
Updated to v3.1.0-stable.20240615
Sandakan Jun 15, 2024
1fa88a6
Temperorily removed flatpak due to build error
Sandakan Jun 15, 2024
76c6d30
Updated to v3.1.0-stable.20240617
Sandakan Jun 17, 2024
8dcb05a
Merge branch 'master' into minor-release
Sandakan Jun 18, 2024
ce631e5
Fixed Nora not importing/exporting theme data
Sandakan Jun 18, 2024
8fe8b8e
Merge branch 'minor-release' of https://github.com/Sandakan/Nora into…
Sandakan Jun 18, 2024
d191db0
Added file associations .icns files
Sandakan Jun 18, 2024
c2d2a1c
Fixed incorrect file associations .icns paths
Sandakan Jun 18, 2024
c8fb97b
Fixed incorrect file associations .icns paths
Sandakan Jun 18, 2024
6fa818f
Fixed non-library songs not showing in Last.FM
Sandakan Jun 23, 2024
7cd905d
Enabled test and lint workflows
Sandakan Jun 23, 2024
e77aa3b
Added a blurred background to full and mini player
Sandakan Jul 12, 2024
9dec16a
Added new shortcut to open the shortcuts prompt
Sandakan Aug 29, 2024
3910674
Create vi.json
ElectroHeavenVN Aug 30, 2024
a9a1629
Update i18n.ts
ElectroHeavenVN Aug 30, 2024
886c279
Run npm run prettier-write
ElectroHeavenVN Aug 30, 2024
f795e72
added skip lyrics lines functionality to mini and full screen player
Sandakan Sep 1, 2024
b6258b0
Added volume control to full-screen player.
Sandakan Sep 1, 2024
808acbf
Merge remote-tracking branch 'upstream/minor-release' into minor-release
ElectroHeavenVN Sep 1, 2024
47c64b6
Update vi.json
ElectroHeavenVN Sep 1, 2024
5806c9c
Added full translation support for lyrics.
Sandakan Sep 5, 2024
2757dc3
Fixed test fail due to parseLyrics function errors
Sandakan Sep 7, 2024
9f85e6f
Fixed a bug where manually synced lyrics aren't saved to songs.
Sandakan Sep 7, 2024
0519692
Migrated to tanstack-store for state management
Sandakan Sep 17, 2024
312bb07
prettier-write run
Sandakan Sep 17, 2024
8ed3357
Merge pull request #278 from Sandakan/feat-tanstack-store
Sandakan Sep 17, 2024
2528a6b
Merge remote-tracking branch 'upstream/minor-release' into minor-release
ElectroHeavenVN Sep 19, 2024
091c2a0
Update vi.json
ElectroHeavenVN Sep 19, 2024
a006043
Update vi.json
ElectroHeavenVN Sep 19, 2024
db603cf
Fix Discord RPC timestamp and localization
ElectroHeavenVN Sep 19, 2024
6895123
Update App.tsx
ElectroHeavenVN Sep 19, 2024
659d582
Improve Discord Rich Presence
ElectroHeavenVN Sep 22, 2024
265cd7e
lint and prettier-write
ElectroHeavenVN Sep 22, 2024
1b85e76
fix localization
ElectroHeavenVN Sep 22, 2024
1b76135
Update discord.js
ElectroHeavenVN Sep 22, 2024
e998f8c
Update filesystem.ts
ElectroHeavenVN Sep 22, 2024
72321f5
Moved localStorage state to the tanstack store.
Sandakan Sep 23, 2024
adb43c0
add romanization
ElectroHeavenVN Sep 24, 2024
9680740
Merge branch 'romaji' into new-features
ElectroHeavenVN Sep 24, 2024
5f9bf06
add success and error notifications
ElectroHeavenVN Sep 24, 2024
194f331
fix parse lyrics
ElectroHeavenVN Sep 24, 2024
9573596
remove 'by'
ElectroHeavenVN Sep 25, 2024
60d8974
covnert Chinese lyrics, add reset lyrics button
ElectroHeavenVN Sep 25, 2024
373f2b2
convert Korean lyrics
ElectroHeavenVN Sep 25, 2024
8b89fad
Merge remote-tracking branch 'upstream/minor-release' into minor-release
ElectroHeavenVN Sep 25, 2024
af1388a
Merge branch 'minor-release' into new-features
ElectroHeavenVN Sep 25, 2024
bfc17dd
lint and prettier-write
ElectroHeavenVN Sep 25, 2024
ba32af0
Update convertToRomaja.ts
ElectroHeavenVN Sep 25, 2024
68656c9
localize Google Translate message
ElectroHeavenVN Sep 25, 2024
0ebb947
Merge branch 'minor-release' into new-features
ElectroHeavenVN Sep 25, 2024
bc6ea27
Auto translate & convert lyrics
ElectroHeavenVN Sep 26, 2024
fd1c3d3
Update LyricsSettings.tsx
ElectroHeavenVN Sep 26, 2024
ab746e6
Update LyricsContainer.tsx
ElectroHeavenVN Sep 26, 2024
2996724
Update romanizeLyrics.ts
ElectroHeavenVN Sep 26, 2024
bf57340
Update LyricsPage.tsx
ElectroHeavenVN Sep 26, 2024
29d585f
Update LyricsContainer.tsx
ElectroHeavenVN Sep 26, 2024
b3514b0
Added support for viewing app data export progress
Sandakan Sep 29, 2024
9fec7ed
Fixed artist name margin issue in SongInfoPage
Sandakan Oct 1, 2024
477c23f
Merge pull request #277 from ElectroHeavenVN/minor-release
Sandakan Oct 1, 2024
a099204
Added possible fix for devtools theme not changing
Sandakan Oct 1, 2024
94df9cc
convert enhanced lyrics
ElectroHeavenVN Oct 2, 2024
e4a4a5e
Merge remote-tracking branch 'upstream/minor-release' into new-features
ElectroHeavenVN Oct 2, 2024
ed59530
Update LyricLine.tsx
ElectroHeavenVN Oct 2, 2024
71f28b0
Update discordRPC.ts
ElectroHeavenVN Oct 2, 2024
05747a0
fix lyrics conversion
ElectroHeavenVN Oct 2, 2024
bc795f2
Compact lyrics
ElectroHeavenVN Oct 3, 2024
f2a3758
Update LyricLine
ElectroHeavenVN Oct 3, 2024
68b54f4
Update getTranslatedLyrics.ts
ElectroHeavenVN Oct 3, 2024
ca01a4a
Fixed app export not saving artworks correctly.
Sandakan Oct 4, 2024
371d426
fix lyrics apperance
ElectroHeavenVN Oct 5, 2024
1a132dc
fix auto convert/translate lyrics
ElectroHeavenVN Oct 5, 2024
5e37060
Fixed app usage not working in latest Windows
Sandakan Oct 11, 2024
5ec0925
Fixed lyrics not updating right after modifying.
Sandakan Oct 19, 2024
4c53e01
Merge remote-tracking branch 'upstream/minor-release' into new-features
ElectroHeavenVN Oct 26, 2024
14bc1d1
Fixed multiple selections not updating songs.
Sandakan Nov 3, 2024
9c7304a
Fixed incorrect error handling practices.
Sandakan Nov 7, 2024
d6575a2
Fixed event listeners not being detached correctly
Sandakan Nov 7, 2024
2919cc4
Merge remote-tracking branch 'upstream/minor-release' into new-features
ElectroHeavenVN Dec 4, 2024
2dca1de
Update romanized lyrics
ElectroHeavenVN Dec 4, 2024
79346d6
Refactor
ElectroHeavenVN Dec 4, 2024
a5fce0c
Updated app dependencies.
Sandakan Dec 4, 2024
f5f5229
Fixed incompatible peer deps
Sandakan Dec 4, 2024
2accfef
Merge pull request #282 from ElectroHeavenVN/new-features
Sandakan Dec 4, 2024
6b26b0a
Fixed outdated lock file error and lyrics pinyin import error
Sandakan Dec 4, 2024
21de522
Update parseLyrics.test.ts
ElectroHeavenVN Dec 5, 2024
88f7b17
change pinyin library to pinyin-pro
ElectroHeavenVN Dec 9, 2024
c252304
refactor
ElectroHeavenVN Dec 9, 2024
f2c5a37
fix non-Chinese characters in lyrics
ElectroHeavenVN Dec 9, 2024
189c767
Update romanizeLyrics.ts
ElectroHeavenVN Dec 9, 2024
144f4db
Merge pull request #292 from ElectroHeavenVN/new-features
Sandakan Dec 9, 2024
b112e60
Added possible fix for missing sharp dependency in linux
Sandakan Dec 9, 2024
51d13e0
Fixed incorrect command lint command listed in pull_request_template
Sandakan Dec 11, 2024
627e73d
Change Kuroshiro library, fix errors and warnings in the `npm run lin…
ElectroHeavenVN Dec 12, 2024
24e4459
Update LyricsPage.tsx
ElectroHeavenVN Dec 12, 2024
c9c4dac
Merge pull request #293 from ElectroHeavenVN/new-features
Sandakan Dec 12, 2024
25424c8
Added electron-builder asarUnpack entry possibly fix sharp error in l…
Sandakan Dec 12, 2024
dbbe941
Fixed media session metadata not showing
Sandakan Dec 14, 2024
4b5d69d
added relevant configs
Sandakan Dec 15, 2024
b270097
Added possible fix for peer deps conflict when using eslint-v9
Sandakan Dec 15, 2024
b9b9e20
completed eslint migration to v9
Sandakan Dec 24, 2024
0325c0f
Merge pull request #297 from Sandakan/eslint-v9
Sandakan Dec 24, 2024
318fc2c
disabled eslint linting in ci/cd workflow temperorily
Sandakan Dec 24, 2024
0fc4102
updated deps
Sandakan Dec 24, 2024
2cf2cba
Updated deps
Sandakan Dec 27, 2024
ba0c246
Updated tsconfig to target ES2022 and moduleResolution to bundler
Sandakan Dec 27, 2024
7ed644e
Merge pull request #298 from Sandakan/tsconfig-nodenext
Sandakan Dec 27, 2024
9b47363
Completed pino-logger migration
Sandakan Jan 4, 2025
102aaa1
Moved to winston logger
Sandakan Jan 5, 2025
40a2367
Removed incorrect error logic using logger function
Sandakan Jan 5, 2025
d045084
Fixed tests that uses updated logger functions
Sandakan Jan 5, 2025
3c601f5
Added support for saving renderer logs to the log file
Sandakan Jan 14, 2025
6491939
Merge pull request #300 from Sandakan/update-logger
Sandakan Jan 14, 2025
2a12148
Migrated from deprecated registerFileProtocol function
Sandakan Jan 14, 2025
0131096
Reused deprecated registerFileProtocol to debug player error
Sandakan Jan 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add success and error notifications
run npm lint and prettier-write
ElectroHeavenVN committed Sep 24, 2024
commit 5f9bf0657214ad0c96dc61c615fcfdacebdbb059
4 changes: 3 additions & 1 deletion src/@types/app.d.ts
Original file line number Diff line number Diff line change
@@ -260,7 +260,7 @@ declare global {
interface LyricLine {
originalText: string | SyncedLyricsLineWord[]; // Original text of the lyric line
translatedTexts: TranslatedLyricLine[]; // Array of translations in different languages
romanizedLyrics: string | SyncedLyricsLineWord[];
romanizedLyrics: string | SyncedLyricsLineWord[]; // Romanized lyrics
start?: number; // Timing start (for synced lyrics only)
end?: number; // Timing end (for synced lyrics only)
isEnhancedSynced: boolean; // Indicates if the original text is enhanced synced lyrics
@@ -803,6 +803,7 @@ declare global {
| 'OPEN_SONG_IN_EXPLORER_FAILED'
| 'LYRICS_FIND_FAILED'
| 'LYRICS_TRANSLATION_FAILED'
| 'LYRICS_ROMANIZATION_FAILED'
| 'METADATA_UPDATE_FAILED'
| 'DESTINATION_NOT_SELECTED'
| 'ARTWORK_SAVE_FAILED'
@@ -855,6 +856,7 @@ declare global {
| 'LYRICS_SAVED_IN_LRC_FILE'
| 'PENDING_LYRICS_SAVED'
| 'LYRICS_TRANSLATION_SUCCESS'
| 'LYRICS_ROMANIZATION_SUCCESS'
| 'LASTFM_LOGIN_SUCCESS'
| 'APPDATA_EXPORT_STARTED'
| 'APPDATA_IMPORT_STARTED'
4 changes: 2 additions & 2 deletions src/@types/kuromoji-analyzer.d.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ declare class KuromojiAnalyzer {
* @param {Object} [options] JSON object which have key-value pairs settings
* @param {string} [options.dictPath] Path of the dictionary files
*/
constructor({ dictPath: string }: { dictPath?: string; } = {});
constructor({ dictPath: string }: { dictPath?: string } = {});

/**
* Initialize the analyzer
@@ -44,4 +44,4 @@ declare class KuromojiAnalyzer {

declare module 'kuroshiro-analyzer-kuromoji' {
export default KuromojiAnalyzer;
}
}
14 changes: 4 additions & 10 deletions src/@types/kuroshiro.d.ts
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ declare class Kuroshiro {
romajiSystem?: RomanizationSystem;
delimiter_start?: string;
delimiter_end?: string;
},
}
): Promise<string>;
}

@@ -152,10 +152,7 @@ declare namespace Util {
* @param {string} system To which romanization system the given string is converted
* @return {string} Romaji string
*/
export function toRawRomaji(
str: string,
system: RomanizationSystem,
): string;
export function toRawRomaji(str: string, system: RomanizationSystem): string;
/**
* Convert kana to hiragana
*
@@ -177,12 +174,9 @@ declare namespace Util {
* @param {string} system To which romanization system the given string is converted. ["nippon"|"passport"|"hepburn"]
* @return {string} Romaji string
*/
export function kanaToRomaji(
str: string,
system: RomanizationSystem,
): string;
export function kanaToRomaji(str: string, system: RomanizationSystem): string;
}

declare module 'kuroshiro' {
export default Kuroshiro;
}
}
22 changes: 11 additions & 11 deletions src/common/parseLyrics.ts
Original file line number Diff line number Diff line change
@@ -249,7 +249,7 @@ const parseTranslatedLyricsText = (lines: string[]): TranslatedLyricLine[] => {

// MAIN FUNCTIONS //
const parseLyrics = (lrcString: string): LyricsData => {
var isJapanese = false;
let isJapanese = false;
for (let i = 0; i < lrcString.length; i++) {
if (Kuroshiro.Util.isJapanese(lrcString.charAt(i))) {
isJapanese = true;
@@ -299,7 +299,7 @@ const parseLyrics = (lrcString: string): LyricsData => {
start,
end,
romanizedLyrics: '',
isJapanese,
isJapanese
};
}

@@ -318,7 +318,7 @@ const parseLyrics = (lrcString: string): LyricsData => {
start: undefined,
end: undefined,
romanizedLyrics: '',
isJapanese,
isJapanese
};
});

@@ -386,7 +386,7 @@ export const parseSyncedLyricsFromAudioDataSource = (
start: timeStamp / 1000,
end: end / 1000,
isEnhancedSynced: typeof parsedTextLine !== 'string',
romanizedLyrics: '',
romanizedLyrics: ''
};
});

@@ -398,12 +398,12 @@ export const parseSyncedLyricsFromAudioDataSource = (
typeof text === 'string'
? text
: text
.map((x) => {
START_TIMESTAMP_MATCH_REGEX.lastIndex = 0;
if (START_TIMESTAMP_MATCH_REGEX.test(x.unparsedText)) return x.text;
return x.unparsedText;
})
.join(' ');
.map((x) => {
START_TIMESTAMP_MATCH_REGEX.lastIndex = 0;
if (START_TIMESTAMP_MATCH_REGEX.test(x.unparsedText)) return x.text;
return x.unparsedText;
})
.join(' ');
const secs = Math.floor(start % 60);
const secsStr = secs.toString().length > 1 ? secs : `0${secs}`;
const mins = Math.floor(start / 60);
@@ -416,7 +416,7 @@ export const parseSyncedLyricsFromAudioDataSource = (
})
.join('\n');

var isJapanese = false;
let isJapanese = false;
for (let i = 0; i < unparsedLyrics.length; i++) {
if (Kuroshiro.Util.isJapanese(unparsedLyrics.charAt(i))) {
isJapanese = true;
3 changes: 1 addition & 2 deletions src/main/filesystem.ts
Original file line number Diff line number Diff line change
@@ -314,8 +314,7 @@ export function setUserData(dataType: UserDataTypes, data: unknown) {
userData.preferences.sendNowPlayingSongDataToLastFM = data;
} else if (dataType === 'preferences.enableDiscordRPC' && typeof data === 'boolean') {
userData.preferences.enableDiscordRPC = data;
if (!data)
clearDiscordRpcActivity();
if (!data) clearDiscordRpcActivity();
} else if (dataType === 'customMusixmatchUserToken' && typeof data === 'string') {
const encryptedToken = encrypt(data);
userData.customMusixmatchUserToken = encryptedToken;
4 changes: 2 additions & 2 deletions src/main/ipc.ts
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ import checkForStartUpSongs from './core/checkForStartUpSongs';
import checkForNewSongs from './core/checkForNewSongs';
import getTranslatedLyrics from './utils/getTranslatedLyrics';
import { setDiscordRpcActivity } from './other/discordRPC';
import * as Romanizer from './utils/romanizeLyrics'
import * as Romanizer from './utils/romanizeLyrics';

export function initializeIPC(mainWindow: BrowserWindow, abortSignal: AbortSignal) {
if (mainWindow) {
@@ -206,7 +206,7 @@ export function initializeIPC(mainWindow: BrowserWindow, abortSignal: AbortSigna

ipcMain.handle('app/isLyricsJapanese', () => Romanizer.isJapanese());

ipcMain.handle('app/romanizeLyrics', async() => await Romanizer.romanizeLyrics());
ipcMain.handle('app/romanizeLyrics', async () => await Romanizer.romanizeLyrics());

ipcMain.handle('app/saveLyricsToSong', (_, songPath: string, lyrics: SongLyrics) =>
saveLyricsToSong(songPath, lyrics)
2 changes: 1 addition & 1 deletion src/main/utils/getTranslatedLyrics.ts
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ const getTranslatedLyrics = async (languageCode: string) => {
cachedLyrics.lyrics.isTranslated = true;

const translatedLyrics = parseLyrics(lyricsArr.join('\n'));
var romanizedLyrics = cachedLyrics.lyrics.parsedLyrics.map((line) => line.romanizedLyrics);
const romanizedLyrics = cachedLyrics.lyrics.parsedLyrics.map((line) => line.romanizedLyrics);
cachedLyrics.lyrics = translatedLyrics;
cachedLyrics.lyrics.parsedLyrics.map((line, index) => {
line.romanizedLyrics = romanizedLyrics[index];
119 changes: 54 additions & 65 deletions src/main/utils/romanizeLyrics.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { getCachedLyrics, updateCachedLyrics } from '../core/getSongLyrics';
import log from '../log';
import { sendMessageToRenderer } from '../main';
import {
getLrcLyricsMetadata
} from '../core/saveLyricsToLrcFile';
import { getLrcLyricsMetadata } from '../core/saveLyricsToLrcFile';
import { version } from '../../../package.json';
import { INSTRUMENTAL_LYRIC_IDENTIFIER } from '../../common/parseLyrics';
import Kuroshiro from 'kuroshiro';
@@ -14,30 +12,22 @@ const kuroshiro = new Kuroshiro();
await kuroshiro.init(new KuromojiAnalyzer());

const hasJapaneseCharacters = (str: string) => {
if (!str) return false;
var isJapanese = false;
for (let i = 0; i < str.length; i++) {
if (Kuroshiro.Util.isJapanese(str[i])) {
isJapanese = true;
break;
}
if (!str) return false;
let isJapanese = false;
for (let i = 0; i < str.length; i++) {
if (Kuroshiro.Util.isJapanese(str[i])) {
isJapanese = true;
break;
}
return isJapanese;
}
}
return isJapanese;
};

export const isJapanese = () => {
const cachedLyrics = getCachedLyrics();
try {
if (!cachedLyrics) return false;
return hasJapaneseCharacters(cachedLyrics.lyrics.unparsedLyrics);
} catch (error) {
// log('Error occurred when translating lyrics.', { error }, 'ERROR');
// sendMessageToRenderer({
// messageCode: 'LYRICS_TRANSLATION_FAILED'
// });
}
return undefined;
}
if (!cachedLyrics) return false;
return hasJapaneseCharacters(cachedLyrics.lyrics.unparsedLyrics);
};

export const romanizeLyrics = async () => {
const cachedLyrics = getCachedLyrics();
@@ -55,70 +45,69 @@ export const romanizeLyrics = async () => {
const romanizedLyrics: string[] = [];
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (!hasJapaneseCharacters(line))
romanizedLyrics.push("");
if (!hasJapaneseCharacters(line)) romanizedLyrics.push('');
else {
const strsToReplace = [' , ', ' . ', ' ? ', ' ! ', ' ; ', ' ) ', ' ( '];
const strsReplace = [', ' , '. ' , '? ' , '! ' , '; ' , ') ' , ' (' ];
const strsReplace = [', ', '. ', '? ', '! ', '; ', ') ', ' ('];
// var romanized = ' ' + (await kuroshiro.convert(line, { to: 'romaji', mode: 'spaced' })) + ' ';
// for (let j = 0; j < strsToReplace.length; j++) {
// romanized = romanized.replaceAll(strsToReplace[j], strsReplace[j]);
// }
// romanizedLyrics.push(romanized.trim());

//convert lyrics to katakana then to romaji
var kana = await kuroshiro.convert(line, { to: 'katakana', mode: 'spaced' });
const kana = await kuroshiro.convert(line, { to: 'katakana', mode: 'spaced' });

var romanized = ' ' + (Wanakana.toRomaji(kana, { customRomajiMapping: { '「': '「', '」': '」' } })) + ' ';
let romanized =
' ' + Wanakana.toRomaji(kana, { customRomajiMapping: { '「': '「', '」': '」' } }) + ' ';
for (let j = 0; j < strsToReplace.length; j++) {
romanized = romanized.replaceAll(strsToReplace[j], strsReplace[j]);
}
romanizedLyrics.push(romanized.trim());
}
}

const lyricsArr: string[] = [];
const { title, artist, album, lang, length, offset, copyright } =
getLrcLyricsMetadata(cachedLyrics);

lyricsArr.push(`[re:Nora (https://github.com/Sandakan/Nora)]`);
lyricsArr.push(`[ve:${version}]`);
lyricsArr.push(`[ti:${title}]`);

if (artist) lyricsArr.push(`[ar:${artist}]`);
if (album) lyricsArr.push(`[al:${album}]`);
if (lang) lyricsArr.push(`[lang:${lang}]`);
if (length) lyricsArr.push(`[length:${length}]`);
if (typeof offset === 'number') lyricsArr.push(`[offset:${offset}]`);
if (copyright)
lyricsArr.push(`[copyright:${copyright}. Lyrics romanized using Kuroshiro.]`);

for (let i = 0; i < parsedLyrics.length; i++) {
const lyric = parsedLyrics[i];
const romanizedLyric = romanizedLyrics.at(i);

if (romanizedLyric) {
const romanizedText = romanizedLyric.trim();
if (romanizedText !== INSTRUMENTAL_LYRIC_IDENTIFIER)
lyric.romanizedLyrics = romanizedText.replaceAll('\n', '');
}
const { title, artist, album, lang, length, offset, copyright } =
getLrcLyricsMetadata(cachedLyrics);

lyricsArr.push(`[re:Nora (https://github.com/Sandakan/Nora)]`);
lyricsArr.push(`[ve:${version}]`);
lyricsArr.push(`[ti:${title}]`);

if (artist) lyricsArr.push(`[ar:${artist}]`);
if (album) lyricsArr.push(`[al:${album}]`);
if (lang) lyricsArr.push(`[lang:${lang}]`);
if (length) lyricsArr.push(`[length:${length}]`);
if (typeof offset === 'number') lyricsArr.push(`[offset:${offset}]`);
if (copyright) lyricsArr.push(`[copyright:${copyright}. Lyrics romanized using Kuroshiro.]`);

for (let i = 0; i < parsedLyrics.length; i++) {
const lyric = parsedLyrics[i];
const romanizedLyric = romanizedLyrics.at(i);

if (romanizedLyric) {
const romanizedText = romanizedLyric.trim();
if (romanizedText !== INSTRUMENTAL_LYRIC_IDENTIFIER)
lyric.romanizedLyrics = romanizedText.replaceAll('\n', '');
}
}

cachedLyrics.lyrics.isRomanized = true;
cachedLyrics.lyrics.parsedLyrics = parsedLyrics;
cachedLyrics.lyrics.isRomanized = true;
cachedLyrics.lyrics.parsedLyrics = parsedLyrics;

updateCachedLyrics(() => cachedLyrics);
updateCachedLyrics(() => cachedLyrics);

sendMessageToRenderer({
messageCode: 'LYRICS_TRANSLATION_SUCCESS'
});
return cachedLyrics;
sendMessageToRenderer({
messageCode: 'LYRICS_ROMANIZATION_SUCCESS'
});
return cachedLyrics;
} catch (error) {
// log('Error occurred when translating lyrics.', { error }, 'ERROR');
// sendMessageToRenderer({
// messageCode: 'LYRICS_TRANSLATION_FAILED'
// });
log('Error occurred when romanizing lyrics.', { error }, 'ERROR');
sendMessageToRenderer({
messageCode: 'LYRICS_ROMANIZATION_FAILED'
});
}

return undefined;
}
};
2 changes: 1 addition & 1 deletion src/preload/index.ts
Original file line number Diff line number Diff line change
@@ -210,7 +210,7 @@ const lyrics = {

getTranslatedLyrics: (languageCode: LanguageCodes): Promise<SongLyrics | undefined> =>
ipcRenderer.invoke('app/getTranslatedLyrics', languageCode),

isLyricsJapanese: (): Promise<boolean> => ipcRenderer.invoke('app/isLyricsJapanese'),

romanizeLyrics: (): Promise<SongLyrics | undefined> => ipcRenderer.invoke('app/romanizeLyrics'),
2 changes: 2 additions & 0 deletions src/renderer/src/assets/locales/en/en.json
Original file line number Diff line number Diff line change
@@ -1036,7 +1036,9 @@
"GENRE_PALETTE_GENERATING_PROCESS_UPDATE": "Generating palettes for {{value}} out of {{total}} genres.",
"LYRICS_FIND_FAILED": "We couldn't find lyrics for `{{title}}`",
"LYRICS_TRANSLATION_SUCCESS": "Lyrics translated successfully",
"LYRICS_ROMANIZATION_SUCCESS": "Lyrics romanized successfully",
"LYRICS_TRANSLATION_FAILED": "Failed to translate lyrics",
"LYRICS_ROMANIZATION_FAILED": "Failed to romanize Japanese lyrics",
"MUSIC_FOLDER_DELETED": "`{{name}}` folder got deleted from the system. $t(common.songWithCount, {\"count\":{{count}}}) related to that folder will be removed from the library.",
"EMPTY_MUSIC_FOLDER_DELETED": "`{{name}}` folder got deleted from the system. No songs found related to the folder. Library will be unaffected.",
"WHITELISTING_FOLDER_FAILED_DUE_TO_BLACKLISTED_PARENT_FOLDER": "Couldn't whitelist `{{folderName}}` folder because its parent folder '{{parentFolderName}}' is also blacklisted. Whitelist the parent folder to whitelist this folder.",
2 changes: 2 additions & 0 deletions src/renderer/src/assets/locales/vi/vi.json
Original file line number Diff line number Diff line change
@@ -1036,7 +1036,9 @@
"GENRE_PALETTE_GENERATING_PROCESS_UPDATE": "Đang tạo bảng màu cho {{value}} trong tổng số {{total}} thể loại.",
"LYRICS_FIND_FAILED": "Chúng tôi không thể tìm thấy lời cho '{{title}}'",
"LYRICS_TRANSLATION_SUCCESS": "Dịch lời thành công",
"LYRICS_ROMANIZATION_SUCCESS": "Chuyển lời Nhật sang Romaji thành công",
"LYRICS_TRANSLATION_FAILED": "Dịch lời thất bại",
"LYRICS_ROMANIZATION_FAILED": "Thất bại khi chuyển lời Nhật sang Romaji",
"MUSIC_FOLDER_DELETED": "Thư mục '{{name}}' đã bị xoá khỏi hệ thống. $t(common.songWithCount, {\"count\":{{count}}}) liên quan đến thư mục đó sẽ bị xoá khỏi thư viện.",
"EMPTY_MUSIC_FOLDER_DELETED": "Thư mục '{{name}}' đã bị xoá khỏi hệ thống. Không tìm thấy bài hát nào liên quan đến thư mục đó. Thư viện sẽ không bị ảnh hưởng.",
"WHITELISTING_FOLDER_FAILED_DUE_TO_BLACKLISTED_PARENT_FOLDER": "Không thể loại thư mục '{{folderName}}' khỏi danh sách đen vì thư mục mẹ '{{parentFolderName}}' đã có trong danh sách đen. Hãy loại thư mục mẹ ra khỏi danh sách đen để loại thư mục này ra khỏi danh sách đen.",
45 changes: 31 additions & 14 deletions src/renderer/src/components/LyricsPage/LyricLine.tsx
Original file line number Diff line number Diff line change
@@ -35,7 +35,14 @@ const LyricLine = (props: LyricProp) => {
const lyricsRef = useRef(null as HTMLDivElement | null);
const isTheCurrnetLineRef = useRef(false);

const { index, lyric, translatedLyricLines = [], romanizedLyric, syncedLyrics, isAutoScrolling = true } = props;
const {
index,
lyric,
translatedLyricLines = [],
romanizedLyric,
syncedLyrics,
isAutoScrolling = true
} = props;

const handleLyricsActivity = useCallback(
(e: Event) => {
@@ -133,7 +140,6 @@ const LyricLine = (props: LyricProp) => {
});

return extendedLyricLines;

}, [isInRange, romanizedLyric]);

return (
@@ -144,20 +150,23 @@ const LyricLine = (props: LyricProp) => {
title={
syncedLyrics
? t(`lyricsEditingPage.fromTo`, {
start: roundTo(syncedLyrics.start, 2),
end: roundTo(syncedLyrics.end, 2)
})
start: roundTo(syncedLyrics.start, 2),
end: roundTo(syncedLyrics.end, 2)
})
: undefined
}
className={`highlight duration-250 z-0 mb-5 flex w-fit select-none flex-col items-center justify-center text-balance text-center text-5xl font-medium text-font-color-black transition-[transform,color,filter] first:mt-8 last:mb-4 empty:mb-16 dark:text-font-color-white ${syncedLyrics
? `cursor-pointer blur-[1px] ${isInRange
? '!scale-100 text-font-color-highlight !text-opacity-90 !blur-0 dark:!text-dark-font-color-highlight [&>div>span]:!mr-3'
: 'scale-[.7] !text-opacity-20 hover:!text-opacity-75'
}`
className={`highlight duration-250 z-0 mb-5 flex w-fit select-none flex-col items-center justify-center text-balance text-center text-5xl font-medium text-font-color-black transition-[transform,color,filter] first:mt-8 last:mb-4 empty:mb-16 dark:text-font-color-white ${
syncedLyrics
? `cursor-pointer blur-[1px] ${
isInRange
? '!scale-100 text-font-color-highlight !text-opacity-90 !blur-0 dark:!text-dark-font-color-highlight [&>div>span]:!mr-3'
: 'scale-[.7] !text-opacity-20 hover:!text-opacity-75'
}`
: '!text-4xl'
} ${playerType === 'mini' && '!mb-2 !text-2xl !text-font-color-white'} ${playerType === 'full' &&
} ${playerType === 'mini' && '!mb-2 !text-2xl !text-font-color-white'} ${
playerType === 'full' &&
'!mb-6 origin-left !items-start !justify-start !text-left !text-7xl !text-font-color-white'
}`}
}`}
ref={lyricsRef}
onClick={() =>
syncedLyrics && typeof lyric === 'string' && updateSongPosition(syncedLyrics.start)
@@ -187,15 +196,23 @@ const LyricLine = (props: LyricProp) => {
}}
>
{romanizedLyricString && (
<div className={`flex flex-row flex-wrap ${playerType !== 'full' && 'items-center justify-center'} ${syncedLyrics && isInRange ? '!text-xl !text-font-color-black/50 dark:!text-font-color-white/50' : '!text-xl'}`}>{romanizedLyricString}</div>
<div
className={`flex flex-row flex-wrap ${playerType !== 'full' && 'items-center justify-center'} ${syncedLyrics && isInRange ? '!text-xl !text-font-color-black/50 dark:!text-font-color-white/50' : '!text-xl'}`}
>
{romanizedLyricString}
</div>
)}
<div
className={`flex flex-row flex-wrap ${playerType !== 'full' && 'items-center justify-center'}`}
>
{lyricString}
</div>
{translatedLyricString && (
<div className={`translated-lyric-line flex flex-row flex-wrap ${playerType !== 'full' && 'items-center justify-center'} ${syncedLyrics && isInRange ? '!text-xl !text-font-color-black/50 dark:!text-font-color-white/50' : '!text-xl'}`}>{translatedLyricString}</div>
<div
className={`translated-lyric-line flex flex-row flex-wrap ${playerType !== 'full' && 'items-center justify-center'} ${syncedLyrics && isInRange ? '!text-xl !text-font-color-black/50 dark:!text-font-color-white/50' : '!text-xl'}`}
>
{translatedLyricString}
</div>
)}
{syncedLyrics && isInRange && <LyricsProgressBar delay={0} syncedLyrics={syncedLyrics} />}
</div>