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 771643 - Replace Intltool with GNU Gettext
Replace Intltool with GNU Gettext
Status: RESOLVED FIXED
Product: geary
Classification: Other
Component: internationalization
master
Other Linux
: Normal normal
: 0.13.0
Assigned To: Geary Maintainers
Geary Maintainers
branch
Depends on:
Blocks: 722148
 
 
Reported: 2016-09-19 05:09 UTC by Michael Gratton
Modified: 2017-11-03 02:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[Patch] Replace intltool with xgettext (19.23 KB, patch)
2016-12-22 23:06 UTC, Niels De Graef
none Details | Review
[Patch v2] Replace intltool with gettext (21.77 KB, patch)
2017-04-27 09:15 UTC, Niels De Graef
none Details | Review
Translate GSchema (8.64 KB, patch)
2017-11-02 16:31 UTC, Piotr Drąg
none Details | Review

Description Michael Gratton 2016-09-19 05:09:22 UTC
Since intltool is now un-maintained and GNU Gettext now supports at least as many file formats, Geary should be migrated to use Gettext.

Here's some examples:

 - https://blogs.gnome.org/mclasen/2016/07/21/using-modern-gettext/
 - https://blogs.gnome.org/mcatanzaro/2016/07/27/on-the-killing-of-intltool/
 - Bug 769623
Comment 1 Niels De Graef 2016-12-22 23:06:24 UTC
Created attachment 342402 [details] [review]
[Patch] Replace intltool with xgettext

So I took a jab at this, with the attached patch as the result.

Some remarks:
* The minimal supported version of xgettext is 0.19.8. The CMake-script now exits with a fatal error, but I don't know if that is a good choice (if there is an alternative).
* Before merging this, we should probably check this really well (all seems to be ok on first sight, but l10n is not my strong point).
Comment 2 Michael Gratton 2016-12-23 00:47:57 UTC
Review of attachment 342402 [details] [review]:

I've just has a quick look at this, but haven't tried it out yet. There's a few minor nits below but I'm generally happy with the approach.

I think to review it properly I'd need to try it out and understand the migration process a bit better myself, since I'm definitely not a translation expert.

::: CMakeLists.txt
@@ +145,3 @@
+    else ()
+        message(STATUS "xgettext found, version ${XGETTEXT_VERSION}")
+    endif ()

Is it worth incorporating this version check and error message into the xgettext include/macro/whatever, so it works kind of similarly to how pkg_check_modules works? That would de-clutter this change a bit.

::: cmake/Gettext.cmake
@@ +72,3 @@
+
+    # Liberally taken from
+    # https://github.com/boghison/mixcloudscope/blob/master/cmake/FindXGettext.cmake

Does this need proper attribution? What's the copyright & licence on that file?

::: desktop/CMakeLists.txt
@@ +64,3 @@
     message (STATUS "Install Contractor contract: ON")
+    #    if (GETTEXT_FOUND)
+#        INTLTOOL_MERGE_CONTRACT (geary-attach.contract po)

Is this supposed to be commented out?

@@ +78,3 @@
 #            endif (DESKTOP_FILE_VALIDATE_FOUND)
 #        endif (DESKTOP_VALIDATE)
+#    endif (GETTEXT_FOUND)

And this?

::: po/nl.po
@@ +40,3 @@
 msgstr "E-mail verzenden en ontvangen"
 
+#: ../desktop/geary.appdata.xml.in:3

Is this an errant inclusion?

@@ +50,3 @@
 "duidelijke, moderne interface."
 
+#: ../desktop/geary.appdata.xml.in:4

Same with this?
Comment 3 Michael Gratton 2016-12-23 00:50:49 UTC
Piotr, you're my go-to GNOME translation expert, would you mind reviewing this as well if you have a moment?
Comment 4 Piotr Drąg 2016-12-23 01:13:53 UTC
I can't comment on the CMake/build stuff, but I'm able to generate a correct POT file using <https://git.gnome.org/browse/gtk+/tree/make-pot> after removing [type: gettext/glade] tags from po/POTFILES.in.

X-GNOME-FullName in .desktop files doesn't get extracted and it's a known problem (see bug #770080 and bug #771641), but it's deprecated and we can just delete it.

The bigger problem is desktop/geary-attach.contract.in, which I don't know how to get translatable without intltool.
Comment 5 Michael Gratton 2016-12-23 02:07:35 UTC
(In reply to Piotr Drąg from comment #4)
> I can't comment on the CMake/build stuff, but I'm able to generate a correct
> POT file using <https://git.gnome.org/browse/gtk+/tree/make-pot> after
> removing [type: gettext/glade] tags from po/POTFILES.in.
> 
> X-GNOME-FullName in .desktop files doesn't get extracted and it's a known
> problem (see bug #770080 and bug #771641), but it's deprecated and we can
> just delete it.

Thanks!

> The bigger problem is desktop/geary-attach.contract.in, which I don't know
> how to get translatable without intltool.

Yeah, this is support for custom Elementary OS UX. Given they've forked Geary, it might not be worth supporting any more, or maybe it should be a downstream packaging patch anyway.

Niels, do you want to send an email to the list to get some feedback and whether anyone is still using Geary on Elementary?
Comment 6 Niels De Graef 2017-04-27 09:15:05 UTC
Created attachment 350524 [details] [review]
[Patch v2] Replace intltool with gettext

Got in contact with Elementary, and they were able to tell me that the Contract file should work flawlessly with gettext. I investigated it by manually invoking msgfmt, and saw that I forgot to remove the intltool-targeted underscores in the file.

Changes w.r.t. the previous patch:
* Patch is applicable on latest master
* Contract file is only merged and installed conditionally (the proper behaviour)
* POTFILES.in now removes the intltool-specific hints.

Thanks Piotr, Daniel (from Elementary) and Michael for the guidelines!

Now this should normally work, but can anyone check to make sure all goes well?
Comment 7 Michael Gratton 2017-10-23 09:47:03 UTC
Patch rebased of current-ish master pushed and to branch wip/771643-replace-intltool. I'm just waiting on some feedback from gnome-i18n about what needs to happen with Damned Lies before merging this.
Comment 8 Michael Gratton 2017-10-23 10:03:29 UTC
Oh one thing, we still need to provide a convenient way of generating po/geary.pot for translators that is compatible with Damned Lies, since they can no longer just run intltool, and "make pot_file" hasn't been working on master for ages it seems and continues to not work with this patch.

So either we should provide something like the make-pot script that Piotr mentioned exists for GTK+ and that uses the same xgettext args that Damned Lies does (maybe this means adding a po/Makevars file?), or fix the root Makefile and/or cmake build to provide a target that is compatible with whatever gets generated when using autotools — "make geary.pot" or similar.
Comment 9 Piotr Drąg 2017-10-23 15:52:08 UTC
In the last few months the situation has slightly changed, and just adding po/Makevars will allow Damned Lies to build a pot file.

As for the .contract file, you need a custom ITS rule.
Comment 10 Michael Gratton 2017-10-26 06:15:08 UTC
Just pushed some updates to wip/771643-replace-intltool:

 - Added a po/Makevars
 - Re-enabled the "pot_file" make target to replace intltool-update
 - Worked around xgettext not recognising contract files by default

Seems to all work reasonably well - the generated geary.pot file matches l10n.g.o's pretty closely. I'll probably merge sometime in the next few days.
Comment 11 Piotr Drąg 2017-10-26 14:19:28 UTC
> +XGETTEXT_OPTIONS = --from-code=UTF-8 --add-comments --keyword=C_:1c,2 --keyword=NC_:1c,2

This should most likely be “--from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments”.

> +MSGID_BUGS_ADDRESS = gnome-i18n@gnome.org

Please use https://bugzilla.gnome.org/enter_bug.cgi?product=geary&keywords=I18N+L10N&component=internationalization instead, the translators mailing list is not the best choice for bug reports about Geary itself. :)

> +USE_MSGCTXT = no

Geary uses msgctxt, so it should be set to “yes”.

These is also X-GNOME-FullName in desktop/geary-autostart.desktop.in that you didn’t remove.

And replying to myself:

> As for the .contract file, you need a custom ITS rule.

ITS files are for translating custom XML files, so it obviously wouldn’t work.
Comment 12 Michael Gratton 2017-10-30 23:01:54 UTC
Hey Piotr, thanks for the comments.

(In reply to Piotr Drąg from comment #11)
> > +XGETTEXT_OPTIONS = --from-code=UTF-8 --add-comments --keyword=C_:1c,2 --keyword=NC_:1c,2
> 
> This should most likely be “--from-code=UTF-8 --keyword=_ --keyword=N_
> --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3
> --add-comments”.

I've added these in. From my reading from the Gettext docs theose additional keywords were already included by default for Vala source files, but maybe I'm missing something here.

> > +MSGID_BUGS_ADDRESS = gnome-i18n@gnome.org
> 
> Please use
> https://bugzilla.gnome.org/enter_bug.
> cgi?product=geary&keywords=I18N+L10N&component=internationalization instead,
> the translators mailing list is not the best choice for bug reports about
> Geary itself. :)

Good point, done. :)

> > +USE_MSGCTXT = no
> 
> Geary uses msgctxt, so it should be set to “yes”.

Ditto. :)

> These is also X-GNOME-FullName in desktop/geary-autostart.desktop.in that
> you didn’t remove.

Done!

I've updated the wip branch with these changes, will merge with master in a day or two.
Comment 13 Michael Gratton 2017-11-02 07:59:53 UTC
Okay, this has been merged to master as commit d4ea866. Will keep this open for a few days in case there's any feedback.
Comment 14 Michael Gratton 2017-11-02 08:17:28 UTC
Errr, actually commit 2a0fa4c because git - how does it work? ¯\_(ツ)_/¯
Comment 15 Piotr Drąg 2017-11-02 16:31:09 UTC
Created attachment 362844 [details] [review]
Translate GSchema

It’s a great opportunity to translate desktop/org.gnome.Geary.gschema.xml for our advanced users.
Comment 16 Michael Gratton 2017-11-03 02:13:09 UTC
Cool - pushed as commit c6481c6. Thanks for those extra fixes you pushed to master as well.