Skip to content

Commit f8fc9d7

Browse files
author
Patrick Schlarmann
committed
Merge branch 'voice-language-support-table-row-per-variant' into 'main'
docs(voice): One row per variant in Voice Language Support table See merge request deepl-org/deepl/clapi-track/api-docs-mirror!258
2 parents 14ebffa + b939736 commit f8fc9d7

2 files changed

Lines changed: 26 additions & 21 deletions

File tree

‎docs/voice/supported-voice-languages.mdx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ Translation is always provided by DeepL. For some languages, transcription and t
1212
| Arabic | ⎋ | ✓ | ⎋ |
1313
| Bengali | ⎋ | ✓ | — |
1414
| Bulgarian | ⎋ | ✓ | ⎋ |
15-
| Chinese (Simplified/Traditional) | ✓ | ✓ | ✓ |
15+
| Chinese (simplified) | ✓ | ✓ | ✓ |
16+
| Chinese (traditional) | ✓ | ✓ | ✓ |
1617
| Croatian | ⎋ | ✓ | ⎋ |
1718
| Czech | ✓ | ✓ | ⎋ |
1819
| Danish | ⎋ | ✓ | ⎋ |
1920
| Dutch | ✓ | ✓ | ✓ |
20-
| English (American/British) | ✓ | ✓ | ✓ |
21+
| English (American) | ✓ | ✓ | ✓ |
22+
| English (British) | ✓ | ✓ | ✓ |
2123
| Estonian | ⎋ | ✓ | — |
2224
| Finnish | ⎋ | ✓ | ⎋ |
23-
| French (France/Canada <Badge color="blue">beta</Badge>) | ✓ | ✓ | ✓/⎋ |
25+
| French | ✓ | ✓ | ✓ |
26+
| French (Canadian) <Badge color="blue">beta</Badge> | ✓ | ✓ | ⎋ |
2427
| German | ✓ | ✓ | ✓ |
2528
| Greek | ⎋ | ✓ | ⎋ |
2629
| Hebrew | ⎋ | ✓ | — |
@@ -37,7 +40,8 @@ Translation is always provided by DeepL. For some languages, transcription and t
3740
| Maltese | ⎋ | ✓ | — |
3841
| Norwegian (bokmål) | ⎋ | ✓ | ⎋ |
3942
| Polish | ✓ | ✓ | ✓ |
40-
| Portuguese (Brazil/Portugal) | ✓ | ✓ | ✓ |
43+
| Portuguese (Brazilian) | ✓ | ✓ | ✓ |
44+
| Portuguese (European) | ✓ | ✓ | ✓ |
4145
| Romanian | ✓ | ✓ | ⎋ |
4246
| Russian | ✓ | ✓ | ✓ |
4347
| Slovak | ⎋ | ✓ | ⎋ |

‎scripts/generate-voice-languages.mjs‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
import { fileURLToPath } from 'node:url';
99
import { byCode, byName, fetchLanguages, parseArgs, replaceBlock } from './lib.mjs';
1010

11-
// The matrix folds target-only variants into their base language's row.
12-
const MATRIX_NAME_OVERRIDES = {
13-
en: 'English (American/British)',
14-
fr: 'French (France/Canada <Badge color="blue">beta</Badge>)',
15-
pt: 'Portuguese (Brazil/Portugal)',
16-
zh: 'Chinese (Simplified/Traditional)',
17-
};
18-
1911
// feature values are objects like { status, external? }; presence means the
2012
// capability exists, external: true means an external partner provides it
2113
export const mark = (feature) => (feature ? (feature.external ? '⎋' : '✓') : '—');
@@ -25,19 +17,28 @@ export async function update({ authKey, dryRun = false }) {
2517
const sources = languages.filter((l) => l.usable_as_source);
2618
const targets = languages.filter((l) => l.usable_as_target);
2719

28-
// The matrix only shows source languages (variants fold into the base row),
29-
// so a target-only language without a source base would silently vanish.
30-
const sourceBases = new Set(sources.map((l) => l.lang.split('-')[0]));
31-
for (const t of targets.filter((t) => !sourceBases.has(t.lang.split('-')[0]))) {
32-
console.warn(`voice target ${t.lang} has no source base language and is missing from the matrix`);
33-
}
20+
const languagesByCode = new Map(languages.map((language) => [language.lang, language]));
3421

35-
const rows = sources
36-
.map((l) => ({ ...l, name: MATRIX_NAME_OVERRIDES[l.lang] ?? l.name }))
22+
const rows = languages
23+
// Skip the row for a base language if variants are available
24+
.filter((l) => l.lang.includes('-') || !languages.some((f) => f.lang.startsWith(`${l.lang}-`)))
3725
.sort(byName)
3826
.map((l) => {
27+
const isVariant = l.lang.includes('-');
28+
const baseCode = l.lang.split('-')[0];
29+
const base = languagesByCode.get(baseCode);
30+
31+
if (isVariant && !base) {
32+
console.warn(`voice variant ${l.lang} has no base language (${baseCode})`);
33+
}
34+
35+
// Transcription for variants is determined by base language, if it exists
36+
const transcription = isVariant
37+
? (base?.features?.transcription ?? l.features.transcription)
38+
: l.features.transcription;
3939
const name = l.status !== 'stable' ? `${l.name} <Badge color="blue">beta</Badge>` : l.name;
40-
return `| ${name} | ${mark(l.features.transcription)} | ✓ | ${mark(l.features.translated_speech)} |`;
40+
41+
return `| ${name} | ${mark(transcription)} | ✓ | ${mark(l.features.translated_speech)} |`;
4142
});
4243
const matrix = [
4344
'| **Language** | **Transcription** | **Translation** | **Translated Speech** |',

0 commit comments

Comments
 (0)