Skip to content

Commit

Permalink
bug/ENG-17965.fix-language-code-mapping (#26)
Browse files Browse the repository at this point in the history
Add Language code mapper
  • Loading branch information
mkante-lilt authored Oct 21, 2024
1 parent 8fe8aca commit 8ca44e4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Plugin/tmgmt/Translator/LiltTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;

const DRUPAL_LANG_FILTER_MAP = [
'zh' => 'zt', // drupal language code ===> Lilt language code
];

/**
* Lilt translation plugin controller.
*
Expand Down Expand Up @@ -658,6 +662,12 @@ public function getLiltProject($project_id) {
public function getTranslationMemories($trglang = '') {
$output = [];
$memories = $this->sendApiRequest('memories');

// If there is a Drupal language code map, then use it.
if (array_key_exists($trglang, DRUPAL_LANG_FILTER_MAP)) {
$trglang = DRUPAL_LANG_FILTER_MAP[$trglang];
}

if (is_array($memories)) {
foreach ($memories as $memory) {
if ($trglang == '' || $memory['trglang'] == $trglang) {
Expand Down

0 comments on commit 8ca44e4

Please sign in to comment.