From 8ca44e4e858e7541f8b5729de303365a2478e37d Mon Sep 17 00:00:00 2001 From: mkante-lilt <139250253+mkante-lilt@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:17:19 -0400 Subject: [PATCH] bug/ENG-17965.fix-language-code-mapping (#26) Add Language code mapper --- src/Plugin/tmgmt/Translator/LiltTranslator.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Plugin/tmgmt/Translator/LiltTranslator.php b/src/Plugin/tmgmt/Translator/LiltTranslator.php index e139024..1245c0c 100644 --- a/src/Plugin/tmgmt/Translator/LiltTranslator.php +++ b/src/Plugin/tmgmt/Translator/LiltTranslator.php @@ -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. * @@ -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) {