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

Prevent plural translations errors when not logged in; fixes #2949 #2950

Merged
merged 1 commit into from
Oct 12, 2017
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
12 changes: 9 additions & 3 deletions inc/autoload.function.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ function _e($str, $domain='glpi') {
function _n($sing, $plural, $nb, $domain='glpi') {
global $TRANSLATE;

if (is_null($TRANSLATE)) { // before login
if ($nb == 0 || $nb > 1) {
return $plural;
} else {
return $sing;
}
}

return $TRANSLATE->translatePlural($sing, $plural, $nb, $domain);
}

Expand All @@ -185,8 +193,6 @@ function _n($sing, $plural, $nb, $domain='glpi') {
* @return protected string (with htmlentities)
**/
function _sn($sing, $plural, $nb, $domain='glpi') {
global $TRANSLATE;

return htmlentities(_n($sing, $plural, $nb, $domain), ENT_QUOTES, 'UTF-8');
}

Expand Down Expand Up @@ -344,4 +350,4 @@ function glpi_autoload($classname) {
require_once $autoload;

// Use spl autoload to allow stackable autoload.
spl_autoload_register('glpi_autoload', false, true);
spl_autoload_register('glpi_autoload', false, true);