Skip to content

Commit

Permalink
fix(form_language): filter out obsolete translations
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jan 31, 2023
1 parent 35315ca commit b38555c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions inc/form_language.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,18 @@ public function showTranslations($options = []) {
echo $header;
echo '</thead>';

$all_translated_strings = $form->getTranslatableStrings([
'translated' => true,
'language' => $this->fields['name']
]);

echo '<tbody>';
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 '<tr data-itemtype="PluginFormcreatorTranslation" data-id="' . $id . '">';
echo '<td>'
. Html::getCheckbox([
Expand Down
2 changes: 1 addition & 1 deletion inc/translation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<td colspan="2">' . __('Iternal error : translatable string not found.', 'formcreator') . '</td>';;
}

$type = $translatableString['id'][$id] ?? 'string';
Expand Down

0 comments on commit b38555c

Please sign in to comment.