Xgettext don't extract strings from .ui files

I’m trying to generate a .pot file for my application, but apparently xgettext is ignoring all .ui files in potfiles.in and only reading desktop.in and metainfo.xml.in. The command I’m using is:

xgettext --files-from=POTFILES.in --directory=.. --output=messages.pot --from-code=UTF-8 --verbose

It doesn’t seem to be a file path error, xgettext doesn’t give any error, it just doesn’t extract anything from the .ui. If I try to use it directly on a .ui instead of using potfiles, it doesn’t generate any output.

I’m running the command in the VScode terminal, I also tried running it in the OS terminal, but in this case, besides it not working either, I get the following message:

xgettext: warning: ITS ruleset file "/usr/share/gettext-0.22.5/its/gtkbuilder.its" was used; it may not be in sync with upstream

Just to be sure, do you have translatable="yes" set in the tags you want to translate?

E.g.

<property name="label" translatable="yes">A nice label</property>
1 Like

You also could check the glib preset for gettext in meson to see if you’re missing any flags: meson/mesonbuild/modules/i18n.py at b3f9b9dc06fcd6c0a3070380b42e0ab5fd6c1226 · mesonbuild/meson · GitHub.

1 Like

It generally helps to have access to the source code when troubleshooting. Where is the repository?

1 Like

The source code, it’s a very little and simple app.

@rafaelmardojai I have translatable="true", that is the way workbench put it. I don’t think it has anything to do with meson, this command is not executed by meson, it is executed manually by me.

Why use xgettext? Have you tried meson compile poliedros-pot?

https://mesonbuild.com/Localisation.html

I have translatable="true", that is the way workbench put it.

This is a bug that is already fixed in git Workbench. Converting to XML file sets translatable="true" rather than "yes" · Issue #957 · workbenchdev/Workbench · GitHub

Edit: Apparently there haven’t been a new release after that :frowning:

1 Like

@ajonsson I can try changing it to “yes” just to be safe.

@afranke No special reason other than the fact that I learned it this way, I’ll try meson compile and see what happens.

Okay, the problem was the “true”, I ended up changing just one label to translatable="yes" and the file was read normally. Thank you very much everyone.

Ps: I would never have thought that the workbench was generating the wrong format.

1 Like

Workbench is generating a valid UI definition file: GTK accepts true|false, yes|no, and 1|0. The problem is that an older version of the ITS file used by xgettext to extract the translatable strings only accepts yes|no: Strings from many .ui files are no longer translatable (#4596) · Issues · GNOME / gtk · GitLab

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.