I have program with multiple domains, some source files contain dgettext() calls with different text domains.
How to extract gettext-strings to multiple .po files? For example, call dgettext('one', 'Hello')
should go to one.po, and dgettext('two', 'Bye')
to two.po. xgettext just ignores text domain and puts everything in single file.
First you need a way of separating the domains.
For instance, let's say you have a domain for lib and one for app, then create a shortcut for the dgettext()
call;
_app(msg) -> dgettext("app", msg);
and one for the lib domain:
_lib(msg) -> dgettext("lib", msg);
Add these calls all over your code, like this;
show_message(_app("Choose a directory to save your work."));
show_message(_lib("No space left on device."));
Remember that you need to call bindtextdomain()
for both domains when initializing your application.
To extract them you need to specify different keywords to xgettext
on all the filenames in your source tree that contains these markers:
xgettext --keyword=_app -d domain1 filenames...
xgettext --keyword=_lib -d domain2 filenames...
Finally, compile both of the .po files into their binary .mo variant and copy/install them to the right location.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With