Add a setting to treat -1 as singular

To ensure that all languages get always their right singular form
or plural form its better to let the user choice whether '-1' should
be interpreted as singular form.
This commit is contained in:
B1N4RYJ4N 2021-09-04 23:57:46 +02:00
parent 14bb04d285
commit 2370612386
No known key found for this signature in database
GPG Key ID: 5C5BEC9486AF648E
2 changed files with 4 additions and 1 deletions

View File

@ -22,6 +22,9 @@ Setting('MODE', 'production');
// one of the other available localization folders in the "/localization" directory
Setting('DEFAULT_LOCALE', 'en');
// For most languages it might be a good idea to treat -1 as singular
Setting('TREAT_MINUS_ONE_AS_SINGULAR', true);
// This is used to define the first day of a week for calendar views in the frontend,
// leave empty to use the locale default
// Needs to be a number where Sunday = 0, Monday = 1 and so forth

View File

@ -73,7 +73,7 @@ class LocalizationService
{
$this->CheckAndAddMissingTranslationToPot($singularForm);
return sprintf($this->Translator->ngettext($singularForm, $pluralForm, $number), $number);
return sprintf($this->Translator->ngettext($singularForm, $pluralForm, GROCY_TREAT_MINUS_ONE_AS_SINGULAR ? abs($number) : $number), $number);
}
public function __t($text, ...$placeholderValues)