HooksBridging language codes
Bridging language codes
Sometimes WordPress and your translation provider use different codes for the same language.
This applies to the "classic" providers, not AI-based ones.
- Google Translate
- DeepL
Example: WordPress uses "nb"
for Norwegian, but Google Translate expects "no"
.
If you run into a mismatch between WordPress and your translation provider's language codes, just map the codes so the provider gets what it expects.
Do this via hook:
gatompl:language_mapping_variables
The hook receives the following parameters:
Parameter | Description | Example |
---|---|---|
$languageMapping | The mapping of language codes for each provider | ['google_translate' => ['nb' => 'no']] |
add_filter(
'gatompl:language_mapping_variables',
/**
* @param array<string, array<string, string>> $languageMapping
* @return array<string, array<string, string>>
*/
function (array $languageMapping): array {
return [
'google_translate' => [
'nb' => 'no',
// provide your additional mappings
// ...
],
'deepl' => [
// provide your additional mappings
// ...
],
]
}
);