0
votes

POedit/xgettext: create context-specific .po file / string import

Using POedit I'd like to work with 2 separate language files, so translators need only edit one client-specific language file, while the system-specific language file stays intact.

This is my xgettext call:

 xgettext --force-po -o %o %C %F -k --keyword=_e:1,2c

However, this How to get (translatable) strings from specific domain with POEdit gets ALL translatable strings.

Now, I want to create a .po file containing ONLY the strings that match a certain context. This is my PHP:

# CLIENT-specific: should BE imported into .po file
__('Photo challenge', 'imlang_ext');

# SYSTEM-specific: should NOT be imported into .po file
__('An error has occured.', 'imlang_msg');

How can I import only those values that match the imlang_ext context?

1

1 Answers

0
votes

There's no easy way to do that with neither Poedit nor GNU gettext.

If I may, the problem probably is in why you want to do that in the first place. That's not what contexts are for: their purpose is disambiguating otherwise identical strings in the catalog.

Sounds like you're misusing contexts and what you really want is to use two different domains (i.e. separate PO files). Which not-so-coincidentally is what the _e() function's second argument is, a domain and not a context: http://codex.wordpress.org/Function_Reference/_e