Support py.in for intltool-update -m

Bug #493403 reported by fujiwara
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
intltool
Fix Released
Low
Данило Шеган

Bug Description

Currently a lot of sources provide "foo.py.in" files to convert to "foo.py" with configure so I think it would be useful to support "py.in" file extension when you run "intltool-update -m"

To reproduce:
% mkdir po
% cd po
% cat >> ../foo.py.in <<_EOF
#!/usr/bin/python

            # Translators: %(name)s and %(value)s should not be translated:
            # it's a way to identify a string, so just handle them like %s
            print _("%(name)s: %(value)s") % infos_dict

_EOF

% touch POTFILES.in
% intltool-update -m

Then the file is not detected by 'intltool-update -m'.

I'm attaching the patch.

Related branches

Revision history for this message
fujiwara (takao-fujiwara) wrote :
Revision history for this message
Данило Шеган (danilo) wrote :

Thanks for the patch. While it seems good, I wonder what those "lot of sources" are that would benefit from it?

Also, there is one concern I have: you are listing this format as having builtin support in gettext: does xgettext correctly pick up python-format as the syntax for such files?

Changed in intltool:
status: New → Incomplete
Revision history for this message
Данило Шеган (danilo) wrote :

Ok, I've confirmed that xgettext correctly extracts strings even from .py.in files. Now fixed in lp:intltool r710.

Changed in intltool:
status: Incomplete → Triaged
importance: Undecided → Low
assignee: nobody → Данило Шеган (danilo)
status: Triaged → In Progress
status: In Progress → Fix Committed
Changed in intltool:
milestone: none → 0.41.1
Revision history for this message
fujiwara (takao-fujiwara) wrote :

Apologize. I found a regression in the previous attachment.

The previous patch fixes to detect .py.in file but it fails to detect .py file.

% cd po
% intltool-update -m

Could you please replace the commit the new attachment?

Thanks.

Revision history for this message
Данило Шеган (danilo) wrote :

Fixed, thanks again.

Revision history for this message
fujiwara (takao-fujiwara) wrote :

Thanks for your commit.

Just now I noticed comment #2. Oops sorry, it seems I didn't receive email during the new year vacation.

> I wonder what those "lot of sources" are that would benefit from it?

Some of .py config file includes the build parameters with py.in
E.g.

foo.py.in:
datadir="@datadir@"
localedir="@datadir@/locale"
N_ = lambda x: x
FOO_A = N_("test")
FOO_B = N_("test2")

> does xgettext correctly pick up python-format as the syntax for such files?

Yes, I think so.
gettext/gettext-tools/src/xgettext.c:

...
          /* Remove a trailing ".in" - it's a generic suffix. */
          if (strlen (reduced) >= 3
              && memcmp (reduced + strlen (reduced) - 3, ".in", 3) == 0)
            reduced[strlen (reduced) - 3] = '\0';

          /* Work out what the file extension is. */
          extension = strrchr (reduced, '.');
          if (extension)
            ++extension;
          else
            extension = "";

          language = extension_to_language (extension);
...

gettext/gettext-tools/src/x-python.h:
#define EXTENSIONS_PYTHON \
  { "py", "Python" }, \

Thanks.

Changed in intltool:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.