Skip to content

Commit

Permalink
feat(DropdownField): Load translation for plugin too
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz authored and btry committed Sep 11, 2023
1 parent 78d4d41 commit 6af1766
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions inc/field/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
use QueryUnion;
use GlpiPlugin\Formcreator\Exception\ComparisonException;
use Glpi\Application\View\TemplateRenderer;
use Plugin;

class DropdownField extends PluginFormcreatorAbstractField
{
const ENTITY_RESTRICT_USER = 1;
Expand Down Expand Up @@ -713,6 +715,9 @@ public function parseObjectProperties(
// We need english locale to search searchOptions by name
$oldLocale = $TRANSLATE->getLocale();
$TRANSLATE->setLocale("en_GB");
if ($plug = isPluginItemType($itemtype)) {
Plugin::loadLang(strtolower($plug['plugin']), "en_GB");
}

$item = new $itemtype;
$item->getFromDB($answer);
Expand Down Expand Up @@ -774,6 +779,10 @@ public function parseObjectProperties(
}
// Put the old locales on succes or if an expection was thrown
$TRANSLATE->setLocale($oldLocale);
if ($plug = isPluginItemType($itemtype)) {
Plugin::loadLang(strtolower($plug['plugin']), $oldLocale);
}

return $content;
}

Expand Down

0 comments on commit 6af1766

Please sign in to comment.