Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DropdownField): Load translation for plugin too #3377

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions inc/field/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ public function parseObjectProperties(
// We need english locale to search searchOptions by name
$oldLocale = $TRANSLATE->getLocale();
$TRANSLATE->setLocale("en_GB");
$_SESSION['glpilanguage'] = "en_GB";
Copy link
Collaborator

@btry btry Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could maybe replace $TRANSLATE->setLocale("en_GB"); and $_SESSION['glpilanguage'] = "en_GB"; with a single call to Session::loadLanguage().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I'm not mistaken Session::loadLanguage(). does not overload $_SESSION['glpilanguage'] with $forcelang

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Then I approve this solution.

if ($plug = isPluginItemType($itemtype)) {
Plugin::loadLang(strtolower($plug['plugin']), "en_GB");
}
Expand All @@ -736,6 +737,7 @@ public function parseObjectProperties(
if (count($searchOption) == 0) {
trigger_error("No search option found for $property", E_USER_WARNING);
$TRANSLATE->setLocale($oldLocale);
$_SESSION['glpilanguage'] = $oldLocale;
return $content;
}

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