After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 726990 - (TC2) Provide plural forms: "%i application and %i add-ons installed"
(TC2)
Provide plural forms: "%i application and %i add-ons installed"
Status: RESOLVED FIXED
Product: gnome-software
Classification: Applications
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Software maintainer(s)
GNOME Software maintainer(s)
: 737650 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-03-24 20:04 UTC by Peter Mráz
Modified: 2015-02-19 20:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sources dialog: Break up a sentence for easier translation (3.38 KB, patch)
2014-03-25 14:24 UTC, Kalev Lember
needs-work Details | Review
Second attempt to handle '%i applications and %i add-ons installed' correctly (4.16 KB, patch)
2015-02-19 00:06 UTC, Rafal Luzynski
accepted-commit_now Details | Review

Description Peter Mráz 2014-03-24 20:04:23 UTC
src/gs-sources-dialog.c:104
msgid "%i application and %i add-ons installed"
msgid_plural "%i applications and %i add-ons installed"

why only one plural form in this string, please split this string and add plural form for both
Comment 1 Peter Mráz 2014-03-24 20:11:23 UTC
sorry no separation needed sentence can be translated to Slovak by changing word order without separation
Comment 2 Peter Mráz 2014-03-24 20:16:31 UTC
sorry separation is needed anyway
Bola nainštalovaná 1 aplikácia a 1 doplnok
Bola nainštalovaná 1 aplikácia a 2 doplnky
Bola nainštalovaná 1 aplikácia a 5 doplnkov
Bola nainštalovaná 2 aplikácie a 1 doplnok
Bola nainštalovaná 2 aplikácie a 2 doplnky
Bola nainštalovaná 2 aplikácie a 5 doplnkov
Comment 3 Kalev Lember 2014-03-25 14:24:15 UTC
Created attachment 272855 [details] [review]
sources dialog: Break up a sentence for easier translation

Construct the "%i applications and %i add-ons installed" sentence from
chunks to make plural form handling more correct.
Comment 4 Kalev Lember 2014-03-25 14:28:49 UTC
Peter, is this the way you wanted the strings split up?
Comment 5 André Klapper 2014-03-25 15:03:23 UTC
That would be against https://wiki.gnome.org/TranslationProject/DevGuidelines/Never%20split%20sentences ... :-/
Comment 6 Kalev Lember 2014-03-25 15:14:58 UTC
Yeah, pointers and help appreciated how to best do this.
Comment 7 Rafal Luzynski 2014-09-04 01:04:12 UTC
I'm afraid that this cannot be reasonably solved without splitting. Even in English and probably in all languages. This is a kind of enumeration: we have "application(s)" and "add-on(s)". This already gives 4 combinations. What if we had to enumerate more items, like "game(s)", "translator(s)", "debugger(s)", "browser(s)", "other(s)" in one sentence? Therefore I like Kalev's patch.

But there is one problem not yet mentioned: in some languages adjectives and participles ("installed" in our case) have numbers, too. Peter's example from comment 2 correctly should be:

Bola nainštalovaná 1 aplikácia a 1 doplnok
Bola nainštalovaná 1 aplikácia a 2 doplnky
Bola nainštalovaná 1 aplikácia a 5 doplnkov
Bola nainštalovaná 2 aplikácie a 1 doplnok
Boli nainštalované 2 aplikácie a 5 doplnkov
Bolo nainštalovaných 5 aplikácií a 2 doplnky

And the correct form of "installed" depends on... surprise: the number of applications. In other languages it may depend on the number of add-ons or both. So this cannot be implemented this way because even if we called ngettext() we would not know which value to pass as the argument: cnt_apps or cnt_addons. Peter, sorry, I cannot speak Slovak, but is it correct to use impersonal and independent on the number form, something like:

Nainštalovano 1 aplikáciu a 1 doplnok
Nainštalovano 2 aplikácie a 5 doplnkov
Nainštalovano 5 aplikácií a 2 doplnky

This is even closer to English "installed" because the former is closer to "has/have been installed".
Comment 8 Rafal Luzynski 2014-09-30 00:22:48 UTC
Review of attachment 272855 [details] [review]:

Since there is no other review, here is my attempt. I like the idea of splitting this sentence and I think it is the best solution regarding the complexity of some languages. The current approach is not correct in most languages including English so whatever we do it will be only better. Please find my suggestions to improve the patch and make it handle correctly even more languages.

::: src/gs-sources-dialog.c
@@ +99,3 @@
+	addons_text = g_strdup_printf (ngettext ("%i add-on",
+	                                         "%i add-ons",
+	                                         cnt_addon), cnt_addon);

For the reasons I explain below I suggest moving these initializations to the last else block.

@@ +107,3 @@
+		/* TRANSLATORS: This string is used to construct the 'X applications
+		   installed' sentence, describing a software source. */
+		text = g_strdup_printf (_("%s installed"), apps_text);

I suggest leaving this block unchanged. Currently the text is correct, the modification does not change it but adds more work to the translators.

@@ +111,3 @@
+		/* TRANSLATORS: This string is used to construct the 'X add-ons
+		   installed' sentence, describing a software source. */
+		text = g_strdup_printf (_("%s installed"), addons_text);

I suggest leaving this block unchanged for the same reason as above. But here please note that the current (old) comment for translators is incorrect: refers to "apps" while should refer to "add-ons". The new comment is correct.

@@ +114,1 @@
 	} else {

I suggest moving the initialization of apps_text and addons_text here because they would not be used in other cases.

@@ +115,3 @@
+		/* TRANSLATORS: This string is used to construct the 'X applications
+		   and y add-ons installed' sentence, describing a software source. */
+		text = g_strdup_printf (_("%s and %s installed"), apps_text, addons_text);

I like the idea of splitting this sentence, despite what the rules say. But I have already identified some languages (cs, sk, sl, sr, lv?, lt?) where the correct form of "installed" must be agreed with the number of applications so it should be something like:

    ngettext ("%s and %s installed|singular_app",
              "%s and %s installed|plural_apps",
              cnt_apps), ...

and it must be stated clearly in the translators' comment that it is only for those languages which need this. Note about the pipe characters: do whatever is appropriate to make the translation possible. By the way, I have also identified some languages (fr, pt, es, sv?) which need the correct form of "installed" agreed with the total number of apps+addons which is at least 2 so the number is always plural.

I don't know if it is possible to support those languages without these complex rules but I hope this solution works.

@@ +119,3 @@
 	widget = gtk_label_new (text);
+	g_free (apps_text);
+	g_free (addons_text);

If you move the initialization and allocation to the last else block then maybe also move g_free() to this block? Alternatively, initialize these variables to NULL to avoid g_free()ing garbage.
Comment 9 Rafal Luzynski 2014-09-30 08:24:09 UTC
(In reply to comment #8)
> But I
> have already identified some languages (cs, sk, sl, sr, lv?, lt?) where the
> correct form of "installed" must be agreed with the number of applications so
> it should be something like:
> 
>     ngettext ("%s and %s installed|singular_app",
>               "%s and %s installed|plural_apps",
>               cnt_apps), ...
> 
> and it must be stated clearly in the translators' comment that it is only for
> those languages which need this.

Hey, what about this solution, would it work for all languages?

	addons_text = g_strdup_printf (ngettext ("%i add-on",
	                                         "%i add-ons",
	                                         cnt_addon), cnt_addon);
	text = g_strdup_printf (ngettext ("%i application and %s installed",
	                                  "%i applications and %s installed",
	                                  cnt_apps), cnt_apps, addons_text);
Comment 10 Kalev Lember 2014-09-30 09:56:02 UTC
*** Bug 737650 has been marked as a duplicate of this bug. ***
Comment 11 Abderrahim Kitouni 2014-09-30 10:46:16 UTC
Review of attachment 272855 [details] [review]:

Just my 2 cents regarding this issue.

::: src/gs-sources-dialog.c
@@ +107,3 @@
+		/* TRANSLATORS: This string is used to construct the 'X applications
+		   installed' sentence, describing a software source. */
+		text = g_strdup_printf (_("%s installed"), apps_text);

I agree with the suggestion albeit for a different reason. Translator comments aren't used to differentiate context. The two strings would end up in the same msgstr with two different comments.

@@ +115,3 @@
+		/* TRANSLATORS: This string is used to construct the 'X applications
+		   and y add-ons installed' sentence, describing a software source. */
+		text = g_strdup_printf (_("%s and %s installed"), apps_text, addons_text);

> By the way, I have also identified some languages 
> (fr, pt, es, sv?) which need the correct form of 
> "installed" agreed with the total number of 
> apps+addons which is at least 2 so the number is 
> always plural.

You can add ar to the list, and 2 is not plural in all languages.
Comment 12 Rafal Luzynski 2014-09-30 20:22:33 UTC
Abderrahim, thank you for your comment. We need to take non-European languages into account but most of us can't do it without help. Please take a look at comment 9 and explain if it is possible to provide a correct translation in your language with this implementation or not, and why not and what is missing.

Should we prepare a new version of the patch to focus on it?
Comment 13 Abderrahim Kitouni 2014-09-30 20:50:25 UTC
No, it isn't possible because we need to take into account the total number (apps + add-ons) for translating "installed"
Comment 14 Rafal Luzynski 2014-10-01 23:00:56 UTC
Then we need something closer to Kalev's original patch:

	/* TRANSLATORS: This string is used to construct the 'X applications
	   and y add-ons installed' sentence, describing a software source.
	   You can use the correct form of 'installed' here if it depends
	   on the number and/or gender of applications in your language. */
	apps_text = g_strdup_printf (ngettext ("%i application",
	                                       "%i applications",
	                                       cnt_apps), cnt_apps);
	/* TRANSLATORS: This string is used to construct the 'X applications
	   and y add-ons installed' sentence, describing a software source.
	   You can use the correct form of 'installed' here if it depends
	   on the number and/or gender of add-ons in your language. */
	addons_text = g_strdup_printf (ngettext ("%i add-on",
	                                         "%i add-ons",
	                                         cnt_addon), cnt_addon);
	/* TRANSLATORS: This string is used to construct the 'X applications
	   and y add-ons installed' sentence, describing a software source.
	   You should use the correct form of 'installed' here if it depends
	   on the total number of applications and add-ons in your language. */
	text = g_strdup_printf (ngettext ("%s and %s installed",
	                                  "%s and %s installed",
	                                  cnt_apps + cnt_addon),
	                                  apps_text, addons_text);

AFAIK it should not be a problem that msgid and msgid_plural are the same in the last ngettext(). Those who need "installed" depending on the number of applications probably will translate "%i application(s)" like "%i application(s) installed" or "Installed %i application(s)" and then "%s and %s installed" like "%s and %s". Those who need "installed" depending on the total number and those who do not need any difference will translate it more naturally. Unfortunately the strings for just applications (and no add-ons) and for just add-ons (no applications) must be processed in separate branches because the correct form of "installed" may not depend only on the number of applications/add-ons but also on the grammatical gender of the words "application" and "add-on". We can't expect that an universal form of "%s installed" exists in every language and it will work if we substitute %s with a correct number+form of applications, add-ons, or both.
Comment 15 Kalev Lember 2014-10-03 20:37:21 UTC
Thanks for the comments and ideas everyone. Let's try to land this after 3.14.1 when we branch for 3.16.
Comment 16 Kalev Lember 2015-02-17 17:27:41 UTC
I've now pushed a version of this patch, taking into account what Rafal suggested in comment #14. Not sure if we need to provide translation context for these strings -- please let me know if I should add that or change anything else.

Thanks for the help everyone!

Attachment 272855 [details] pushed as a8c4497 - sources dialog: Break up a sentence for easier translation
Comment 17 Rafal Luzynski 2015-02-19 00:06:23 UTC
Created attachment 297235 [details] [review]
Second attempt to handle '%i applications and %i add-ons installed' correctly

Unfortunately there are still some issues in some languages, for example in Slovak which is the native language of the original reporter. The English string "%s installed" is ambiguous because "%s" may refer to "application(s)" or "add-on(s)" and in many languages the correct form of "installed" must depend on the grammatical gender of "application"/"add-on". Another problem is that in the sentence "%i application(s) and %i add-on(s) installed" the correct form of "installed" and even "and" may depend on the number of application, the number of add-ons (probably this never occurs), or the total number of applications and add-ons. During the IRC session Matthias said that the best solution would be to rework the sentence and agreed that it is a good idea to display the numbers of applications and add-ons in a bulleted list. But then we have stated that we may have not enough place for the list. So here we try to come back to the original idea.

With this patch the basic translation is:
* '%i application(s)' depends on the number of applications,
* '%i add-on(s)' depends on the number of add-ons,
* '%s and %s installed' depends on the total number of applications and add-ons which may not be trivial in some languages (see comment #11 and comment #13).
If the words 'and' and/or 'installed' depend on the number of applications or add-ons in some language the translator must translate them together with '%i application(s)' or '%i add-on(s)', respectively, and translate '%s and %s installed' as '%s and %s' or even '%s %s'.

Please review the patch and do whatever you find appropriate: reject, accept, rework, comment, use as an inspiration, etc.

I can see that there are new translations to: Spanish, Russian, Slovenian, and Slovak already in git. I apologize the translators, you will have to revert some of your changes.
Comment 18 Kalev Lember 2015-02-19 20:36:02 UTC
Review of attachment 297235 [details] [review]:

Looks good to me, thanks!