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 778786 - Plural forms in transitPlan.js fails to be offered for translation
Plural forms in transitPlan.js fails to be offered for translation
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
git master
Other Linux
: Normal minor
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
: 778927 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-02-16 18:59 UTC by Anders Jonsson
Modified: 2017-02-20 20:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
transitPlan: Use ngettext for pluralized durations (2.34 KB, patch)
2017-02-17 12:51 UTC, Marcus Lundblad
committed Details | Review

Description Anders Jonsson 2017-02-16 18:59:38 UTC
Hi,
I started translating gnome-maps on l10n.gnome.org but saw 3 strings that doesn't have a plural form. 


#: ../src/transitPlan.js:271
#, javascript-format
msgid "%d minute"
msgstr "n"

#: ../src/transitPlan.js:278
#, javascript-format
msgid "%d hour"
msgstr ""

#: ../src/transitPlan.js:280
#, javascript-format
msgid "%d:%0d hour"
msgstr ""

Looking at the code shows lines like
"return N_("%d minute", "%d minutes", mins).format(mins);", so the plural forms are in the code, but l10n.gnome.org does not pick them up for translation.
Comment 1 Anders Jonsson 2017-02-16 20:32:03 UTC
Looking at the description of gettext commands I wonder if

"const N_ = imports.gettext.dgettext;" should be 
"const N_ = imports.gettext.ngettext;" instead in src/transitPlan.js.

This is not enough to fix the problem for me though.
Comment 2 Marcus Lundblad 2017-02-17 10:30:11 UTC
Apparently Polari is just using "ngettext()" directly, see: https://git.gnome.org//browse/polari/tree/src/userList.js#n234 . Maybe this is why it doesn't end up in the .pot file (that we define and use N_( ?).
Comment 3 Marcus Lundblad 2017-02-17 12:51:32 UTC
Created attachment 346066 [details] [review]
transitPlan: Use ngettext for pluralized durations

Use ngettext() directly for pluralized translated strings
dealing with durations of itineraries.
Inspiration was taken from Polari.
Comment 4 Anders Jonsson 2017-02-17 16:18:16 UTC
(In reply to Marcus Lundblad from comment #3)
> Created attachment 346066 [details] [review] [review]
> transitPlan: Use ngettext for pluralized durations
> 
> Use ngettext() directly for pluralized translated strings
> dealing with durations of itineraries.
> Inspiration was taken from Polari.

Tested "make update-po" after applying this, and the plural forms are now in the translation correctly. Looks good to me.
Comment 5 Piotr Drąg 2017-02-19 23:06:44 UTC
*** Bug 778927 has been marked as a duplicate of this bug. ***
Comment 6 Jonas Danielsson 2017-02-20 13:41:16 UTC
Review of attachment 346066 [details] [review]:

\o/
Comment 7 Marcus Lundblad 2017-02-20 20:13:33 UTC
Attachment 346066 [details] pushed as cb1743e - transitPlan: Use ngettext for pluralized durations