Skip to content

Commit b38555c

Browse files
committed
fix(form_language): filter out obsolete translations
1 parent 35315ca commit b38555c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

inc/form_language.class.php

+9
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,18 @@ public function showTranslations($options = []) {
356356
echo $header;
357357
echo '</thead>';
358358

359+
$all_translated_strings = $form->getTranslatableStrings([
360+
'translated' => true,
361+
'language' => $this->fields['name']
362+
]);
363+
359364
echo '<tbody>';
360365
foreach ($translations as $original => $translated) {
361366
$id = PluginFormcreatorTranslation::getTranslatableStringId($original);
367+
if (!in_array($id, array_keys($all_translated_strings['id']))) {
368+
// String is translated but no longer used in the form or its sub objects
369+
continue;
370+
}
362371
echo '<tr data-itemtype="PluginFormcreatorTranslation" data-id="' . $id . '">';
363372
echo '<td>'
364373
. Html::getCheckbox([

inc/translation.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public static function getEditorFieldsHtml(PluginFormcreatorForm_Language $formL
161161
if (!isset($translatableString['id'][$id])) {
162162
// Show nothing if string definitively not found
163163
// Should not happen
164-
return '';
164+
return '<td colspan="2">' . __('Iternal error : translatable string not found.', 'formcreator') . '</td>';;
165165
}
166166

167167
$type = $translatableString['id'][$id] ?? 'string';

0 commit comments

Comments
 (0)