mirror of
				https://github.com/grocy/grocy.git
				synced 2025-10-31 18:49:38 +00:00 
			
		
		
		
	Use singular localization form when plural form is not provided (closes #1878)
This commit is contained in:
		| @@ -11,6 +11,7 @@ | |||||||
| - New product option "Move on open" (defaults to disabled) | - 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 |   - When enabled, on marking the product as opened, the corresponding amount will be moved to the products default consume location | ||||||
|   - (Thanks @RosemaryOrchard) |   - (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 | - 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 | ### Shopping list | ||||||
|   | |||||||
| @@ -257,6 +257,11 @@ __n = function(number, singularForm, pluralForm, isQu = false) | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if (pluralForm.isEmpty()) | ||||||
|  | 	{ | ||||||
|  | 		pluralForm = singularForm; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if (isQu) | 	if (isQu) | ||||||
| 	{ | 	{ | ||||||
| 		return Grocy.TranslatorQu.n__(singularForm, pluralForm, Math.abs(number), Math.abs(number)) | 		return Grocy.TranslatorQu.n__(singularForm, pluralForm, Math.abs(number), Math.abs(number)) | ||||||
|   | |||||||
| @@ -78,6 +78,11 @@ class LocalizationService | |||||||
| 	{ | 	{ | ||||||
| 		$this->CheckAndAddMissingTranslationToPot($singularForm); | 		$this->CheckAndAddMissingTranslationToPot($singularForm); | ||||||
|  |  | ||||||
|  | 		if (empty($pluralForm)) | ||||||
|  | 		{ | ||||||
|  | 			$pluralForm = $singularForm; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		if ($isQu) | 		if ($isQu) | ||||||
| 		{ | 		{ | ||||||
| 			return sprintf($this->TranslatorQu->ngettext($singularForm, $pluralForm, abs(floatval($number))), $number); | 			return sprintf($this->TranslatorQu->ngettext($singularForm, $pluralForm, abs(floatval($number))), $number); | ||||||
| @@ -218,6 +223,7 @@ class LocalizationService | |||||||
| 				$translation = new Translation('', $quantityUnit['name']); | 				$translation = new Translation('', $quantityUnit['name']); | ||||||
| 				$translation->setTranslation($quantityUnit['name']); | 				$translation->setTranslation($quantityUnit['name']); | ||||||
| 				$translation->setPlural($quantityUnit['name_plural']); | 				$translation->setPlural($quantityUnit['name_plural']); | ||||||
|  |  | ||||||
| 				$translation->setPluralTranslations(preg_split('/\r\n|\r|\n/', $quantityUnit['plural_forms'])); | 				$translation->setPluralTranslations(preg_split('/\r\n|\r|\n/', $quantityUnit['plural_forms'])); | ||||||
|  |  | ||||||
| 				$this->PoQu[] = $translation; | 				$this->PoQu[] = $translation; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user