From e8771cbabf74cfcb86167c965285c80333b32315 Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Tue, 3 Dec 2024 14:48:44 +0200 Subject: [PATCH] Fixed questionnaire translation process --- .../QuestionnaireLanguageManager.php | 4 ++ app/Utils/Translator.php | 5 ++ .../common/StoreModalComponent.vue | 54 +------------------ .../questionnaire/QuestionnaireCreateEdit.vue | 6 ++- .../questionnaire/QuestionnaireLanguages.vue | 6 +-- .../questionnaire/QuestionnaireStatistics.vue | 12 +++-- resources/assets/sass/shared/modal.scss | 51 ++++++++++++++++++ 7 files changed, 76 insertions(+), 62 deletions(-) diff --git a/app/BusinessLogicLayer/Questionnaire/QuestionnaireLanguageManager.php b/app/BusinessLogicLayer/Questionnaire/QuestionnaireLanguageManager.php index 4a7a7205..710e7863 100644 --- a/app/BusinessLogicLayer/Questionnaire/QuestionnaireLanguageManager.php +++ b/app/BusinessLogicLayer/Questionnaire/QuestionnaireLanguageManager.php @@ -31,6 +31,10 @@ public function saveLanguagesForQuestionnaire(array $lang_codes, int $questionna $existingQuestionnaireLanguages = $this->getLanguagesForQuestionnaire($questionnaire_id); $languagesToDelete = $existingQuestionnaireLanguages->pluck('language.language_code')->toArray(); for ($i = 0; $i < count($lang_codes); $i++) { + // fix for Greek language code + if ($lang_codes[$i] === 'gr') { + $lang_codes[$i] = 'el'; + } if (in_array($lang_codes[$i], $languagesToDelete)) { array_splice($languagesToDelete, array_search($lang_codes[$i], $languagesToDelete), 1); } diff --git a/app/Utils/Translator.php b/app/Utils/Translator.php index 7e550a21..635a53b6 100644 --- a/app/Utils/Translator.php +++ b/app/Utils/Translator.php @@ -18,6 +18,11 @@ class Translator { * @throws \Exception */ public static function translateTexts(array $texts, string $lang_code): array { + // fix for Greek language code + if ($lang_code === 'gr') { + $lang_code = 'el'; + } + $translate = new TranslateClient(['key' => config('app.google_translate_key')]); // Google translate capacity is 100 texts per request. // So we need to break the texts into 100-texts batches diff --git a/resources/assets/js/vue-components/common/StoreModalComponent.vue b/resources/assets/js/vue-components/common/StoreModalComponent.vue index ecc6b3a0..68427fa6 100644 --- a/resources/assets/js/vue-components/common/StoreModalComponent.vue +++ b/resources/assets/js/vue-components/common/StoreModalComponent.vue @@ -49,7 +49,7 @@