api/language-codes: remove region part of the language code

and convert language codes if they're not 3 characters long
This commit is contained in:
wukko
2025-07-01 00:56:04 +06:00
parent 4d2c8b0a8c
commit 9b3ebe90c5
2 changed files with 4 additions and 2 deletions

View File

@@ -49,5 +49,6 @@ const maps = {
}
export const convertLanguageCode = (code) => {
code = code.split("-")[0].split("_")[0];
return maps[code.length]?.[code.toLowerCase()] || null;
}