J3 Issue ?
avatar pitu-sk
pitu-sk
27 Mar 2018

Steps to reproduce the issue

Let's play on Merlin and change plurals in English as follow:

  1. We will add 's' if the number is 1, for example:
    1 articles published.

  2. 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
...

Expected result

We would get a messages:
1 articles published.
2 article published.
3 article published.
...

Actual result

We get a messages:
1 article published. (!Merlin English problem - article instead articles)
2 article published.
3 article published.
...

System information (as much as possible)

Joomla 3.8.6

Additional comments

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...

avatar pitu-sk pitu-sk - open - 27 Mar 2018
avatar joomla-cms-bot joomla-cms-bot - change - 27 Mar 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Mar 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 27 Mar 2018
Category Feature Request Language & Strings
avatar infograf768
infograf768 - comment - 27 Mar 2018

Not sure I understand;
Why would you change

elseif ($count == 1)
	{
		return array('1');
	}

TO

elseif ($count == 1)
	{
		return array('MORE');
	}

???

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:

COM_CHECKIN_N_ITEMS_CHECKED_IN_0="No item checked in."
COM_CHECKIN_N_ITEMS_CHECKED_IN_1="1 item checked in."
COM_CHECKIN_N_ITEMS_CHECKED_IN_MORE="%s items checked in."

or

COM_MENUS_ITEMS_SET_HOME_0="Aucun lien de menu assigné à la page d'accueil"
COM_MENUS_ITEMS_SET_HOME_1="1 lien de menu assigné à la page d'accueil."
COM_MENUS_ITEMS_SET_HOME_MORE="%d liens de menus assignés à des pages d'accueil"

Did not test Slovak but its method looks OK, although there is a small mistake in the code.
(see the red ¿)
screen shot 2018-03-27 at 09 36 11

If it is true that $count == 3 should be equal to $count == 2, then something does not look right in these strings

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é."

I guess this should be checked by the Slovak TT Coordinator.
We will contact him.

avatar infograf768
infograf768 - comment - 27 Mar 2018

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

avatar pitu-sk
pitu-sk - comment - 27 Mar 2018

@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

avatar infograf768
infograf768 - comment - 27 Mar 2018

The bug is not in Joomla code, but in the Slovak pack.
I guess you can close #20003

avatar pitu-sk
pitu-sk - comment - 27 Mar 2018

@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.

avatar Bakual
Bakual - comment - 27 Mar 2018

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).

avatar pitu-sk
pitu-sk - comment - 27 Mar 2018

@Bakual

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.

avatar mbabker
mbabker - comment - 27 Mar 2018

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).

avatar infograf768
infograf768 - comment - 27 Mar 2018

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.

avatar franz-wohlkoenig franz-wohlkoenig - change - 28 Mar 2018
Status New Discussion
avatar brianteeman brianteeman - change - 3 Apr 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 3 Apr 2018
avatar brianteeman
brianteeman - comment - 5 Apr 2018

Is there anything left to do here or can it be closed?

avatar pitu-sk
pitu-sk - comment - 5 Apr 2018

It seems that the majority vote for maintaining the original state ...

avatar infograf768 infograf768 - change - 17 Jun 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-06-17 07:18:07
Closed_By infograf768
avatar infograf768 infograf768 - close - 17 Jun 2018

Add a Comment

Login with GitHub to post a comment