Sometimes you are using language labels with arguments and it can happen that you need a singular and plural of a word depending on the argument. For instance for the amout of errors.
XLIFF supports that and the Flow translator as well. But when you want to use that labels in the JS part of the neos-ui you have no possibility to get the plural. You always get the singular if this is the first value in the group.
<group id="validationErrorTooltip" restype="x-gettext-plurals">
<trans-unit id="validationErrorTooltip[0]" xml:space="preserve">
<source>{tabName} – {amountOfErrors} validation issue</source>
</trans-unit>
<trans-unit id="validationErrorTooltip[1]" xml:space="preserve">
<source>{tabName} – {amountOfErrors} validation issues</source>
</trans-unit>
</group>
const notificationTooltipLabelPieces = i18nRegistry.translate(
'validationErrorTooltip',
'',
{
tabName: tabLabel,
amountOfErrors: number
},
'Neos.Neos.Ui'
);
So in this case the label will be in the UI always Our Tab – 2 validation issue instead of Our Tab – 2 validation issues.
Would like to change that and have the plural also in the UI.
Label should be Our Tab – 2 validation issues when using error number higher than one.
Label is singular Our Tab – 2 validation issue
Neos: all
UI: all since ever as the code comes from the old Emberjs UI
It turns out that it is not just an neos-ui issue. The UI consumes the language labels from the xliff endpoint via json. The JSON has been build with the XliffService of teh Neos.Neos package an this service also does not respect the plural parameter.
foreach ($file->getTranslationUnits() as $key => $value) {
$valueToStore = !empty($value[0]['target']) ? $value[0]['target'] : $value[0]['source'];
if ($this->scrambleTranslatedLabels) {
$valueToStore = str_repeat('#', UnicodeFunctions::strlen($valueToStore));
}
$this->setArrayDataValue($labels, str_replace('.', '_', $packageKey) . '.' . str_replace('/', '_', $sourceName) . '.' . str_replace('.', '_', $key), $valueToStore);
}
So we also need to extend the XliffService to extend the JSON. This change will be breaking as I would expect that also others using the xliff endpoint.
So the issue is maybe on hold for neos 6.0.
Awesome. One thought, I didn't check in depth, though: What this doesn't respect are the rules some languages have for plurals, no? Because some have different forms for different amounts of things, not just "one" and "many": https://github.com/neos/flow-development-collection/blob/69c9449e417ebd56ecfda3b04dc46c4a982ef311/Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php#L45-L53
@kdambekalns Indeed there are the keywords and the plural forms are working in the PHP area. We (@bwaidelich @jonnitto) had a short discussion and decided in the first place to support the labels we use and in the neos org I did not find the usage of few and many. In the longterm we should adjust the JS part to also support the few, many and zero plural forms.
To be honest I started way to late with the PRs 🙄
Great feature!
We should explicitly communicate that we don't yet support all CLDR plural categories yet when we announce the feature