Let's play on Merlin and change plurals in English as follow:
We will add 's' if the number is 1, for example:
1 articles published.
We will add nothing if the number is greater than 1, for example:
2 article published.
3(,4,5 and more) article published.
No problem in Joomla, we have all plurals in classic English language pack, so just change the file language\en-GB\en-GB.localise.php
from:
public static function getPluralSuffixes($count)
{
if ($count == 0)
{
return array('0');
}
elseif ($count == 1)
{
return array('1');
}
else
{
return array('MORE');
}
}
to:
public static function getPluralSuffixes($count)
{
if ($count == 0)
{
return array('0');
}
elseif ($count == 1)
{
return array('MORE');
}
else
{
return array('1');
}
}
Log in to the Joomla admin section now - Content/Articles.
A. Mark 1 article and click on Publish button
B. Mark 2 articles and click on Publish button
C. Mark 3 articles and click on Publish button
...
We would get a messages:
1 articles published.
2 article published.
3 article published.
...
We get a messages:
1 article published. (!Merlin English problem - article instead articles)
2 article published.
3 article published.
...
Joomla 3.8.6
We have a similar problem with plural based on count 3 in latest slovak language pack sk-SK_joomla_lang_full_3.8.6v4.
A fix is pretty easy, only change a row 220 in file
libraries\src\Language\Text.php
from:
array_unshift($suffixes, (int) $n);
to:
array_push($suffixes, (int) $n);
I apologize for the quality of my English, which is as good as a translator...
Labels |
Added:
?
|
Category | ⇒ | Feature Request Language & Strings |
BTW, the "issue" you describe above with articles published is just because en-GB simplified their strings. They just have 2 strings:
COM_CONTENT_N_ITEMS_PUBLISHED="%s articles published."
COM_CONTENT_N_ITEMS_PUBLISHED_1="%s article published."
i.e. they do not use COM_CONTENT_N_ITEMS_PUBLISHED_MORE
@infograf768 I agree that in Slovak language pack there are not properly generated plural strings names from Crowdin, and on this basis I have discovered in my opinion this little bug
@infograf768 I am voting for a fix in order to avoid potential problems in the future. Can someone else comment on it? Or then completely remove the line 220 from the code, it makes no sense.
I agree that in Slovak language pack there are not properly generated plural strings names from Crowdin, and on this basis I have discovered in my opinion this little bug
What is wrong with how Crowdin names the strings? It shouldn't actually matter at all how they name it. It's just important that the localise.php matches the generated names.
I agree with @infograf768 that this doesn't sound like an issue with core but an issue within a specific language pack.
Or I don't understand your issue. Going from your original messing around with the localsie.php file, I'd say what you got is expected behavior (JM already explained).
What is wrong with how Crowdin names the strings? It shouldn't actually matter at all how they name it. It's just important that the localise.php matches the generated names.
I think this is what you want to hear about - better plural suffixes in slovak localized files:
COM_CONTENT_N_ITEMS_PUBLISHED_1 for count 1 / Form One on Crowdin, now
COM_CONTENT_N_ITEMS_PUBLISHED_1
COM_CONTENT_N_ITEMS_PUBLISHED_FEW for count 2-4 / Form Few on Crowdin, now
COM_CONTENT_N_ITEMS_PUBLISHED_2
COM_CONTENT_N_ITEMS_PUBLISHED_MANY for count 5-20 / Form Many on Crowdin, in 99% identical to next, may be ignored, now
COM_CONTENT_N_ITEMS_PUBLISHED_3
COM_CONTENT_N_ITEMS_PUBLISHED_OTHERS in 99% cases count over 4 {and in 1% cases count over 20, this may be ignored} / Form Other on Crowdin, now
COM_CONTENT_N_ITEMS_PUBLISHED_MORE
or something like that
I agree with @infograf768 that this doesn't sound like an issue with core but an issue within a specific language pack.
Or I don't understand your issue.
If the "overrided" suffixes obtained from localise.php have not priority to other - then yes, this is not a bug. But I think it is not a good idea.
OK, here's what it looks like is the issue.
With en-GB, if you're aiming to pluralize a string for 3 items, Language::getPluralSuffixes()
returns this array:
array(1) {
[0] =>
string(4) "MORE"
}
This part is fine. The current behavior is to prepend the pluralized number to the suffixes array, so this is the array that gets looped over:
array(2) {
[0] =>
int(3)
[1] =>
string(4) "MORE"
}
Meaning in order it will try to use the strings KEY_3
then KEY_MORE
. With #20003 applied, this lookup array becomes:
array(2) {
[0] =>
string(4) "MORE"
[1] =>
int(3)
}
Now the order is KEY_MORE
then KEY_3
.
Either way I think making this change could be considered a B/C break and shouldn't be considered lightly. But, I can see an argument for both prioritization strategies. To me, since there is already precedent with the existing behavior, the question is if the change has more benefit than keeping the existing behavior (or if the changed behavior has less potential for conflicts, as is apparently the case now).
Just received a message from Drobec ((Slovak TT).
he gives me as example:
eg. 1 = Administrator
2,3,4 - Administratori
5 - Administratorov
10 - Administratorov
Which is indeed what I understood (Please Drobec correct the weird sign in your localise.php)
And I remark again that, if this is what is expected, then
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_0="Nebola odomknutá žiadna reklama."
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_1="%d reklama bola odomknutá."
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_2="%d reklamy boli odomknuté."
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_3="%d reklám bolo odomknutých."
COM_BANNERS_BANNERS_N_ITEMS_CHECKED_IN_MORE="%d reklamy boli odomknuté."
is wrong. Because 2 and 3 should be the same.
Status | New | ⇒ | Discussion |
Labels |
Added:
J3 Issue
|
Is there anything left to do here or can it be closed?
It seems that the majority vote for maintaining the original state ...
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-06-17 07:18:07 |
Closed_By | ⇒ | infograf768 |
Not sure I understand;
Why would you change
TO
???
This makes no sense to me and it works perfectly as it is for English language (or French or the majority of other languages.)
For example we have these strings:
or
Did not test Slovak but its method looks OK, although there is a small mistake in the code.
(see the red ¿)
If it is true that
$count == 3
should be equal to$count == 2
, then something does not look right in these stringsI guess this should be checked by the Slovak TT Coordinator.
We will contact him.