Skip to content

Commit

Permalink
fix(form): remove obsolete translations on update
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jan 31, 2023
1 parent b38555c commit 3cc58ac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2437,6 +2437,16 @@ public function setTranslations(string $language, array $translations) : bool {
return false;
}

// CLeanup obsolete strings
$existing_strings = $this->getTranslatableStrings();
foreach (array_keys($translations) as $original) {
if (!in_array($original, $existing_strings['itemlink'])
&& !in_array($original, $existing_strings['string'])
&& !in_array($original, $existing_strings['text'])) {
unset($translations[$original]);
}
}

$output = "<?php" . PHP_EOL . "return " . var_export($translations, true) . ";";
$written = file_put_contents(
$file,
Expand Down

0 comments on commit 3cc58ac

Please sign in to comment.