mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-08 06:18:28 +00:00
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
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:
parent
4d2c8b0a8c
commit
9b3ebe90c5
@ -49,5 +49,6 @@ const maps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const convertLanguageCode = (code) => {
|
export const convertLanguageCode = (code) => {
|
||||||
|
code = code.split("-")[0].split("_")[0];
|
||||||
return maps[code.length]?.[code.toLowerCase()] || null;
|
return maps[code.length]?.[code.toLowerCase()] || null;
|
||||||
}
|
}
|
||||||
|
@ -263,8 +263,9 @@ export default function({
|
|||||||
|
|
||||||
// extractors usually return ISO 639-1 language codes,
|
// extractors usually return ISO 639-1 language codes,
|
||||||
// but video players expect ISO 639-2, so we convert them here
|
// but video players expect ISO 639-2, so we convert them here
|
||||||
if (defaultParams.fileMetadata?.sublanguage?.length === 2) {
|
const sublanguage = defaultParams.fileMetadata?.sublanguage;
|
||||||
const code = convertLanguageCode(defaultParams.fileMetadata.sublanguage);
|
if (sublanguage && sublanguage.length !== 3) {
|
||||||
|
const code = convertLanguageCode(sublanguage);
|
||||||
if (code) {
|
if (code) {
|
||||||
defaultParams.fileMetadata.sublanguage = code;
|
defaultParams.fileMetadata.sublanguage = code;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user