GNOME Bugzilla – Bug 769623
Replace Intltool with GNU Gettext
Last modified: 2016-09-06 17:17:45 UTC
GNU gettext is now actively maintained upstream which intltool isn’t and it can handle all the files we need to translate.
Created attachment 332914 [details] [review] Replace Intltool with GNU Gettext GNU Gettext 0.19.6 can translate appdata xml files and it is actively maintained which Intltool isn't. xgettext is unable to parse G_GNU_PRINTF annotations so add all the printf style functions from glib and some relevant ones from gio with --flag so the c-format comments are preserved to enable msgfmt -c checks.
Created attachment 332915 [details] [review] Fix translator comments Translator comments need to be prefixed with ‘Translators:’ (NB xgettext is case sensitive) they must also be on the line immediately preceding the translated string. Some translator comments were previously missing from the pot file as they weren’t close enough to the translated string. Also remove the leading ‘*’ from comment continuation lines as xgettext passes them verbatim which messes up the appearance of translator comments in the pot file. Using a prefix remove some unrelated comments from the pot file.
Created attachment 332916 [details] [review] Stop translating icon name Gettext automatically extracts the icon name from the desktop file for translation¹ because it is a locale string in the desktop entry specification.² However we don’t want it translated. As it’s not possible to specify per-language keywords to stop xgettext from extracting the string use sed to remove it from the pot file. ¹ https://savannah.gnu.org/support/?108887 ² http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html
Created attachment 332917 [details] [review] Use unicode quotes xgettext has an option to enforce unicode quotes in translated strings so lets use it.
Created attachment 332918 [details] [review] Use proper ellipsis xgettext has an option to enforce using ‘…’ instead of ‘...’ so lets use it. Unfortunately it doesn’t actually pick up the ellipsis in the UI as it’s not at the end of the string or followed by a space :-(
Review of attachment 332917 [details] [review]: I'm not sure if changing the target strings in PO files is a good idea here. Different languages have different typographic rules and it should be up to language maintainers to decide which characters to use. I'd suggest changing the msgid's only.
Review of attachment 332914 [details] [review]: Have you tested this with l10n.gnome.org yet? If not, we could push the patches to a wip branch and set up a dummy module branch in the Damned Lies admin interface to see if it works.
FWIW, I use https://git.gnome.org/browse/gtk+/tree/make-pot to test gettext changes locally. You just need to adjust it for another module (replace gtk30 with sound-juicer, for example.) Also, I agree with Petr that changing PO files is usually a bad idea. Just update the code, and leave the rest to translators.
Created attachment 333101 [details] [review] Use unicode quotes xgettext has an option to enforce unicode quotes in translated strings so lets use it.
Created attachment 333102 [details] [review] Use proper ellipsis xgettext has an option to enforce using ‘…’ instead of ‘...’ so lets use it. Unfortunately it doesn’t actually pick up the ellipsis in the UI as it’s not at the end of the string or followed by a space :-(
(In reply to Petr Kovar from comment #7) > Review of attachment 332914 [details] [review] [review]: > > Have you tested this with l10n.gnome.org yet? > > If not, we could push the patches to a wip branch and set up a dummy module > branch in the Damned Lies admin interface to see if it works. Thanks for your and Piotr's feedback on editing the PO files I've updated the patches to only change the source strings. I've pushed the changes to wip/gettext, I don't know anything about l10n.gnome.org (or have any permissions to add/change things there) - if you have time to check it works that would be really helpful. Do you know if damned lies avoids extracting the the icon name for translation?
(In reply to Piotr Drąg from comment #8) > FWIW, I use https://git.gnome.org/browse/gtk+/tree/make-pot to test gettext > changes locally. You just need to adjust it for another module (replace > gtk30 with sound-juicer, for example.) Thanks is that a better approximation to what damned-lies does than make sound-juicer.pot? > Also, I agree with Petr that changing PO files is usually a bad idea. Just > update the code, and leave the rest to translators. I've updated the patches now.
(In reply to Phillip Wood from comment #11) > Thanks for your and Piotr's feedback on editing the PO files I've updated > the patches to only change the source strings. I've pushed the changes to > wip/gettext, I don't know anything about l10n.gnome.org (or have any > permissions to add/change things there) - if you have time to check it works > that would be really helpful. Do you know if damned lies avoids extracting > the the icon name for translation? I tested the branch locally and generating .pot file seems to be working, except for extraction of "X-GNOME-FullName" in the .desktop file (isn't that line obsolete, anyway?) and removing "Icon" - but that's probably because of my setup. XGETTEXT_OPTIONS looks like an overkill to me, but if you say the flags are needed, then I certainly believe you. :) And no, damned-lies doesn't do anything with the icon name. I've been adding comments to .desktop files to avoid at least some mistranslations: https://git.gnome.org/browse/polari/commit/?id=98f8a386079e41f1f73bb16a7a046a299294e387 (In reply to Phillip Wood from comment #12) > (In reply to Piotr Drąg from comment #8) > > FWIW, I use https://git.gnome.org/browse/gtk+/tree/make-pot to test gettext > > changes locally. You just need to adjust it for another module (replace > > gtk30 with sound-juicer, for example.) > > Thanks is that a better approximation to what damned-lies does than make > sound-juicer.pot? > Damned-lies can't run autogen.sh/make. See bug #755466. > > Also, I agree with Petr that changing PO files is usually a bad idea. Just > > update the code, and leave the rest to translators. > I've updated the patches now. Thank you!
Created attachment 333177 [details] [review] Add some translator comments to desktop file Gettext automatically extracts the icon name from the desktop file for translation¹ because it is a locale string in the desktop entry specification.² However we don’t want it translated so add a comment to this effect. Also add a comment that the translated keyword list must contain semicolons. Thanks to Piotr Drąg for suggesting these changes. ¹ https://savannah.gnu.org/support/?108887 ² http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html
Created attachment 333178 [details] [review] Stop translating icon name Gettext automatically extracts the icon name from the desktop file for translation¹ because it is a locale string in the desktop entry specification.² However we don’t want it translated. As it’s not possible to specify per-language keywords to stop xgettext from extracting the string use sed to remove it from the pot file. Note that we need to leave the translator comment about the icon name in the desktop file for users of damned-lies as it does not run make to extract the strings and ends up extracting the icon name. The changes to the makefile rule to build the translated desktop file should protect us from any accidental translations. ¹ https://savannah.gnu.org/support/?108887 ² http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html
Created attachment 333179 [details] [review] Remove X-GNOME-FullName key from desktop file This is deprecated. As far as I can tell it is not used by gnome-shell. It is hard to get xgettext to extract it as it's not one of the keys xgettext extracts be default.
(In reply to Piotr Drąg from comment #13) > (In reply to Phillip Wood from comment #11) > I tested the branch locally and generating .pot file seems to be working, > except for extraction of "X-GNOME-FullName" in the .desktop file (isn't that > line obsolete, anyway?) and removing "Icon" - but that's probably because of > my setup. Thanks for testing it. If you used a shell script rather than autogen.sh && make sound-juicer.po then it won't remove the icon name. I think the "X-GNOME-FullName" key is deprecated - I check some modern GNOME apps and they don't use it. GIO has a function to retrieve it but gnome-shell/mutter don't use it as far as I could see. > XGETTEXT_OPTIONS looks like an overkill to me, but if you say the flags are > needed, then I certainly believe you. :) You're right but I decided to take a completest approach as I don't rate my chances of remembering to add new functions in the future. It also means that any contributors don't have to worry if they use any glib/gio functions that are not in the code base right now. I don't think there's any harm to having then there. Personally I'd like libraries to be able to install a file to tell gettext what printf/scanf style functions they have so the developer can just pass one flag per library. Though that approach would be more complicated for language bindings that use GObject Introspection. > And no, damned-lies doesn't do anything with the icon name. I've been adding > comments to .desktop files to avoid at least some mistranslations: > > https://git.gnome.org/browse/polari/commit/ > ?id=98f8a386079e41f1f73bb16a7a046a299294e387 Thanks I've done the same. Also the makefile rule for generating the translated desktop file ignores translations for the "Icon" key. Thanks for your help. Is there anything else that needs addressing or are you happy for me to push these changes?
Looks good to me!
Thanks very much Petr and Piotr your comments and feedback have been really helpful. Attachment 332914 [details] pushed as 006cf24 - Replace Intltool with GNU Gettext Attachment 332915 [details] pushed as 588a52a - Fix translator comments Attachment 333101 [details] pushed as c7a5715 - Use unicode quotes Attachment 333102 [details] pushed as c2f91bc - Use proper ellipsis Attachment 333177 [details] pushed as 00e72da - Add some translator comments to desktop file Attachment 333178 [details] pushed as 10f423b - Stop translating icon name Attachment 333179 [details] pushed as 04feadc - Remove X-GNOME-FullName key from desktop file
small one: re the comments about leading asterisks in continued comment lines, I think you missed a couple here. HTH diff --git a/src/sj-about.c b/src/sj-about.c index 074ebb3..e61639b 100644 --- a/src/sj-about.c +++ b/src/sj-about.c @@ -74,7 +74,7 @@ void show_about_dialog (void) "documenters", documentors, "artists", artists, /* - * Note to translators: put here your name and email so it will show + * Translators: put here your name and email so it will show * up in the "about" box */ "translator-credits", _("translator-credits"),
(In reply to db0451 from comment #20) > small one: re the comments about leading asterisks in continued comment > lines, I think you missed a couple here. HTH > > > diff --git a/src/sj-about.c b/src/sj-about.c > index 074ebb3..e61639b 100644 > --- a/src/sj-about.c > +++ b/src/sj-about.c > @@ -74,7 +74,7 @@ void show_about_dialog (void) > "documenters", documentors, > "artists", artists, > /* > - * Note to translators: put here your name and > email so it will show > + * Translators: put here your name and email so it > will show > * up in the "about" box > */ > "translator-credits", _("translator-credits"), Well spotted, thanks for letting me know, I'll fix that.
Created attachment 334923 [details] [review] Fix translator comment This one was missed when removing the asterisks from translator comments. See commit 588a52a.
Comment on attachment 334923 [details] [review] Fix translator comment Attachment 334923 [details] pushed as 4fe2a8f - Fix translator comment