Skip to content

Commit

Permalink
feat(lyrics-plus): add select language translation for Musixmatch pro…
Browse files Browse the repository at this point in the history
…vider
  • Loading branch information
ianz56 authored Feb 2, 2025
1 parent c3f7c43 commit 38828da
Showing 1 changed file with 20 additions and 70 deletions.
90 changes: 20 additions & 70 deletions CustomApps/lyrics-plus/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,18 @@ const OptionList = ({ type, items, onChange }) => {
);
});
};

const languageCodes = [
"none", "en", "af", "ar", "bg", "bn", "ca", "zh", "cs", "da", "de", "el",
"es", "et", "fa", "fi", "fr", "gu", "he", "hi", "hr", "hu", "id", "is",
"it", "ja", "jv", "kn", "ko", "lt", "lv", "ml", "mr", "ms", "nl", "no",
"pl", "pt", "ro", "ru", "sk", "sl", "sr", "su", "sv", "ta", "te", "th",
"tr", "uk", "ur", "vi", "zu"
];
const displayNames = new Intl.DisplayNames(['en'], { type: 'language' });
const options = languageCodes.reduce((acc, code) => {
acc[code] = code === "none" ? "None" : displayNames.of(code);
return acc;
}, {});
function openConfig() {
const configContainer = react.createElement(
"div",
Expand Down Expand Up @@ -630,72 +641,14 @@ function openConfig() {
max: thresholdSizeLimit.max,
step: thresholdSizeLimit.step,
},
{
desc: "Musixmatch Translation Language.",
info: "Choose the language you want to translate the lyrics to. Changes will take effect after the next track.",
key: "musixmatch-translation-language",
type: ConfigSelection,
options: {
none: "None",
en: "English",
af: "Afrikaans",
ar: "Arabic",
bg: "Bulgarian",
bn: "Bengali",
ca: "Catalan",
zh: "Chinese",
cs: "Czech",
da: "Danish",
de: "German",
el: "Greek",
es: "Spanish",
et: "Estonian",
fa: "Persian",
fi: "Finnish",
fr: "French",
gu: "Gujarati",
he: "Hebrew",
hi: "Hindi",
hr: "Croatian",
hu: "Hungarian",
id: "Indonesian",
is: "Icelandic",
it: "Italian",
pt: "Portuguese",
ja: "Japanese",
jv: "Javanese",
kn: "Kannada",
ko: "Korean",
lt: "Lithuanian",
lv: "Latvian",
ml: "Malayalam",
mr: "Marathi",
ms: "Malay",
nl: "Dutch",
no: "Norwegian",
pl: "Polish",
pt: "Portuguese",
ro: "Romanian",
ru: "Russian",
sk: "Slovak",
sl: "Slovenian",
sr: "Serbian",
su: "Sundanese",
sv: "Swedish",
ta: "Tamil",
te: "Telugu",
th: "Thai",
tr: "Turkish",
uk: "Ukrainian",
ur: "Urdu",
vi: "Vietnamese",
zu: "Zulu",
},
defaultValue:
localStorage.getItem(
`${APP_NAME}:visual:musixmatch-translation-language`
) || "none",
},
{
desc: "Musixmatch Translation Language.",
info: "Choose the language you want to translate the lyrics to. Changes will take effect after the next track.",
key: "musixmatch-translation-language",
type: ConfigSelection,
options: options,
defaultValue: CONFIG.visual["musixmatch-translation-language"] = localStorage.getItem(`${APP_NAME}:visual:musixmatch-translation-language`) || "none",
},
],
onChange: (name, value) => {
CONFIG.visual[name] = value;
Expand Down Expand Up @@ -750,6 +703,3 @@ function openConfig() {
isLarge: true,
});
}
CONFIG.visual["musixmatch-translation-language"] =
localStorage.getItem(`${APP_NAME}:visual:musixmatch-translation-language`) ||
"none";

0 comments on commit 38828da

Please sign in to comment.