From b38555c5e6d0456a49de0be133b59b34c52176bb Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 31 Jan 2023 12:40:56 +0100 Subject: [PATCH] fix(form_language): filter out obsolete translations --- inc/form_language.class.php | 9 +++++++++ inc/translation.class.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/inc/form_language.class.php b/inc/form_language.class.php index 7da37de84..98f9d0da5 100644 --- a/inc/form_language.class.php +++ b/inc/form_language.class.php @@ -356,9 +356,18 @@ public function showTranslations($options = []) { echo $header; echo ''; + $all_translated_strings = $form->getTranslatableStrings([ + 'translated' => true, + 'language' => $this->fields['name'] + ]); + echo ''; foreach ($translations as $original => $translated) { $id = PluginFormcreatorTranslation::getTranslatableStringId($original); + if (!in_array($id, array_keys($all_translated_strings['id']))) { + // String is translated but no longer used in the form or its sub objects + continue; + } echo ''; echo '' . Html::getCheckbox([ diff --git a/inc/translation.class.php b/inc/translation.class.php index 6846f64c2..a909676a1 100644 --- a/inc/translation.class.php +++ b/inc/translation.class.php @@ -161,7 +161,7 @@ public static function getEditorFieldsHtml(PluginFormcreatorForm_Language $formL if (!isset($translatableString['id'][$id])) { // Show nothing if string definitively not found // Should not happen - return ''; + return '' . __('Iternal error : translatable string not found.', 'formcreator') . '';; } $type = $translatableString['id'][$id] ?? 'string';