Use singular localization form when plural form is not provided (closes #1878)

This commit is contained in:
Bernd Bestel 2022-05-14 17:10:48 +02:00
parent e21875bf2a
commit 5406448be0
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 12 additions and 0 deletions

View File

@ -11,6 +11,7 @@
- New product option "Move on open" (defaults to disabled)
- When enabled, on marking the product as opened, the corresponding amount will be moved to the products default consume location
- (Thanks @RosemaryOrchard)
- Optimized that when the plural form(s) of a quantity unit is/are not provided, the singular form is used to display plural amounts
- Fixed "Automatically add products that are below their defined min. stock amount to the shopping list" (stock setting) was only done when consuming products, not when opening them
### Shopping list

View File

@ -257,6 +257,11 @@ __n = function(number, singularForm, pluralForm, isQu = false)
}
}
if (pluralForm.isEmpty())
{
pluralForm = singularForm;
}
if (isQu)
{
return Grocy.TranslatorQu.n__(singularForm, pluralForm, Math.abs(number), Math.abs(number))

View File

@ -78,6 +78,11 @@ class LocalizationService
{
$this->CheckAndAddMissingTranslationToPot($singularForm);
if (empty($pluralForm))
{
$pluralForm = $singularForm;
}
if ($isQu)
{
return sprintf($this->TranslatorQu->ngettext($singularForm, $pluralForm, abs(floatval($number))), $number);
@ -218,6 +223,7 @@ class LocalizationService
$translation = new Translation('', $quantityUnit['name']);
$translation->setTranslation($quantityUnit['name']);
$translation->setPlural($quantityUnit['name_plural']);
$translation->setPluralTranslations(preg_split('/\r\n|\r|\n/', $quantityUnit['plural_forms']));
$this->PoQu[] = $translation;