api/language-codes: remove region part of the language code
Some checks are pending
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Run service tests / test service functionality (push) Waiting to run
Run service tests / test service: ${{ matrix.service }} (push) Blocked by required conditions
Run tests / check lockfile correctness (push) Waiting to run
Run tests / web sanity check (push) Waiting to run
Run tests / api sanity check (push) Waiting to run

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
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2
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;
}

View File

@ -263,8 +263,9 @@ export default function({
// extractors usually return ISO 639-1 language codes,
// but video players expect ISO 639-2, so we convert them here
if (defaultParams.fileMetadata?.sublanguage?.length === 2) {
const code = convertLanguageCode(defaultParams.fileMetadata.sublanguage);
const sublanguage = defaultParams.fileMetadata?.sublanguage;
if (sublanguage && sublanguage.length !== 3) {
const code = convertLanguageCode(sublanguage);
if (code) {
defaultParams.fileMetadata.sublanguage = code;
} else {