diff --git a/providers/deepl/README.md b/providers/deepl/README.md index 31d9ee59..48569df8 100644 --- a/providers/deepl/README.md +++ b/providers/deepl/README.md @@ -51,6 +51,21 @@ or use the default environment variables: To get an API key, register for free at [www.deepl.com/pro#developer](https://www.deepl.com/pro#developer). + ### Beta Languages + + To enable DeepL beta languages (e.g., Croatian, Hindi), add: + + \`\`\`javascript + providerOptions: { + enableBetaLanguages: true, + localeMap: { + HR: 'HR', // Croatian (beta) + } + } + \`\`\` + + Note: Beta languages must also be added to `localeMap` to bypass the locale validation. + ## Limitations: - Only the [deepl supported languages](https://www.deepl.com/docs-api/translating-text/request/) can be translated diff --git a/providers/deepl/lib/index.js b/providers/deepl/lib/index.js index 7c9012ba..0c275c64 100644 --- a/providers/deepl/lib/index.js +++ b/providers/deepl/lib/index.js @@ -31,6 +31,7 @@ module.exports = { typeof providerOptions.apiOptions === 'object' ? providerOptions.apiOptions : {} + const enableBetaLanguages = providerOptions.enableBetaLanguages || apiOptions.enableBetaLanguages || false const glossaries = Array.isArray(providerOptions.glossaries) ? providerOptions.glossaries @@ -110,7 +111,14 @@ module.exports = { texts, parsedSourceLocale, parsedTargetLocale, - { ...apiOptions, tagHandling, glossary } + { ...apiOptions, + tagHandling, + glossary, + extraRequestParameters: { + ...(apiOptions.extraRequestParameters || {}), + ...(enableBetaLanguages ? { enable_beta_languages: '1' } : {}) + } + } ) return result.map((value) => value.text) })