Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with i18n.merge_file #1565

Closed
keszybz opened this issue Apr 5, 2017 · 6 comments
Closed

issue with i18n.merge_file #1565

keszybz opened this issue Apr 5, 2017 · 6 comments

Comments

@keszybz
Copy link
Contributor

keszybz commented Apr 5, 2017

I have the following rule:

i18n.merge_file(
  'org.freedesktop.systemd1.policy',
  po_dir : po_dir,
  input : policy_in,
  output : 'org.freedesktop.systemd1.policy',
  install : true,
  install_dir : polkitpolicydir)

This fails like this:

FAILED: src/core/org.freedesktop.systemd1.policy 
'msgfmt' '--xml' '--template' 'src/core/org.freedesktop.systemd1.policy.in' '-d' '/home/zbyszek/src/systemd/po' '-o' 'src/core/org.freedesktop.systemd1.policy'
msgfmt: cannot locate ITS rules for src/core/org.freedesktop.systemd1.policy.in

I have no idea what "ITS rules" are ;(

Doing it "manually" works:

policy_in = configure_file(
    input : 'org.freedesktop.systemd1.policy.in.in',
    output : 'org.freedesktop.systemd1.policy.in',
    configuration : substs)

custom_target(
   'org.freedesktop.systemd1.policy',
  input : policy_in,
  output : 'org.freedesktop.systemd1.policy',
  command : intltool_command,
  install : true,
  install_dir : polkitpolicydir)

I saw similar message in #1441 (comment), it might be related...

@TingPing
Copy link
Member

TingPing commented Apr 5, 2017

In order for gettext to know what items to translate in an XML file it needs an its file to figure that out. intltool was a custom tool on top of gettext that did this in another method (prefixing with _). So the solution to this is writing an its file, they are very simple and you can see existing ones in /usr/share/gettext/its and http://itstool.org. They can be used locally by passing the data_dirs kwarg.

@keszybz
Copy link
Contributor Author

keszybz commented Apr 6, 2017

Thanks for the reply. I cannot get it to work though. I copied the polkit.its and polkit.loc files from https://cgit.freedesktop.org/polkit/commit/?id=c78819245ff8a270f97c9f800773e727918be838 and installed them into /usr/share/gettext/its. This seems to have no effect — I get the same failure as before. The command that is being run is:

FAILED: src/core/org.freedesktop.systemd1.policy 
'msgfmt' '--xml' '--template' 'src/core/org.freedesktop.systemd1.policy.in' '-d' '/home/zbyszek/src/systemd/po' '-o' 'src/core/org.freedesktop.systemd1.policy'
msgfmt: cannot locate ITS rules for src/core/org.freedesktop.systemd1.policy.in

I tried changing pattern="*.policy" to pattern="*.policy.in", but that has no effect.
Dunno, I'm probably doing something stupid, some help would be appreciated.

I tried also adding data_dirs to my i18n.merge_file rule, but that results in a warning about unknown arg. Where is this supposed to go?

@TingPing
Copy link
Member

TingPing commented Apr 6, 2017

I tried also adding data_dirs to my i18n.merge_file rule, but that results in a warning about unknown arg. Where is this supposed to go?

That might be something overlooked but i18n.gettext() accepts this to extract translations, might have to add it to merge_file() too.

. I copied the polkit.its and polkit.loc files and installed them into /usr/share/gettext/its. This seems to have no effect

Hmm, I'm not sure what the problem is there.

@keszybz
Copy link
Contributor Author

keszybz commented Apr 7, 2017

Ha, so I had the wrong dir: msgformat uses /usr/share/gettext/its/, but there's also /usr/share/itstool/its/ used by itstool. I put the files in the second directory erroneously. Once that's fixed, translations happen.

So this almost works, but I think in current state it's not usable for us, because:

  1. we need to carry the polkit.{its,loc} files in our source tree, since we want to support compilation with older polkit-devel which does not provide them. But w/o data_dirs, there's no way to tell merge_file about them.
  2. I think we want to keep compatibility with the autotools based build system, so we'd need to remove the "_" prefixes by hand. merge_file of course does not remove them...

@TingPing
Copy link
Member

TingPing commented Apr 7, 2017

But w/o data_dirs, there's no way to tell merge_file about them.

For now you can make a custom msgfmt wrapper but I'll work on fixing that in Meson too.

I think we want to keep compatibility with the autotools based build system, so we'd need to remove the "_" prefixes by hand. merge_file of course does not remove them...

Yes you should port that to use upstream gettext also.

TingPing added a commit that referenced this issue Apr 8, 2017
For parity with gettext()

Fixes #1565
TingPing added a commit that referenced this issue Apr 22, 2017
For parity with gettext()

Fixes #1565
@keszybz
Copy link
Contributor Author

keszybz commented Nov 13, 2017

Thanks, I converted systemd to use i18n.merge_file now. Seems to work nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants