It would be cool if XenForo in phrases allowed to use declensions. It's remarkable how the laravel framework does it.
Pluralization
Pluralization is a complex problem, as different languages have a variety of complex rules for pluralization. By using a "pipe" character, you may distinguish singular and plural forms of a string:
You may even create more complex pluralization rules which specify translation strings for multiple number ranges:
After defining a translation string that has pluralization options, you may use the trans_choicefunction to retrieve the line for a given "count". In this example, since the count is greater than one, the plural form of the translation string is returned:
You may also define placeholder attributes in pluralization strings. These placeholders may be replaced by passing an array as the third argument to the trans_choice function:
If you would like to display the integer value that was passed to the trans_choice function, you may use the :count placeholder:
This allows you to get rid of phrases in the plural. Sometimes this is simply necessary and creating phrases for the sake of one and the same comes out somehow silly. + This will help for features of many languages.
Pluralization
Pluralization is a complex problem, as different languages have a variety of complex rules for pluralization. By using a "pipe" character, you may distinguish singular and plural forms of a string:
'apples' => 'There is one apple|There are many apples',
You may even create more complex pluralization rules which specify translation strings for multiple number ranges:
'apples' => '{0} There are none|[1,19] There are some|[20,*] There are many',
After defining a translation string that has pluralization options, you may use the trans_choicefunction to retrieve the line for a given "count". In this example, since the count is greater than one, the plural form of the translation string is returned:
echo trans_choice('messages.apples', 10);
You may also define placeholder attributes in pluralization strings. These placeholders may be replaced by passing an array as the third argument to the trans_choice function:
'minutes_ago' => '{1} :value minute ago|[2,*] :value minutes ago',
echo trans_choice('time.minutes_ago', 5, ['value' => 5]);
If you would like to display the integer value that was passed to the trans_choice function, you may use the :count placeholder:
'apples' => '{0} There are none|{1} There is one|[2,*] There are :count',
This allows you to get rid of phrases in the plural. Sometimes this is simply necessary and creating phrases for the sake of one and the same comes out somehow silly. + This will help for features of many languages.
Upvote
6