If I run find src -iname "*.java" | xargs xgettext -ktrc -ktr -kmarktr -ktrn:1,2 -o po/keys.pot --from-code=utf-8
to create the keys.pot file, then this contains all strings given to i18n::tr, but it also includes all strings given to java.sql.ResultSet::getString like rs.getString("Username")
.
How can I avoid this? I don't want to localize database columns.
With the -k*[keywordspec]* argument of xgettext you can add keywords. The default keyword specifications stay enabled, though. And for Java, these keywords include getString, no matter from which class:
GettextResource.gettext:2
, GettextResource.ngettext:2,3
, GettextResource.pgettext:2c,3
, GettextResource.npgettext:2c,3,4
, gettext
, ngettext:1,2
, pgettext:1c,2
, npgettext:1c,2,3
, getString
.To disable the default keyword specifications, the option ‘-k’ or ‘--keyword’ or ‘--keyword=’, without a keywordspec, can be used.
https://www.gnu.org/software/gettext/manual/gettext.html#Language-specific-options
So, just adding -k with an "empty" keywordspec removes the default keywords.
Considering this, the full command should be:
find src -iname "*.java" | xargs xgettext -k -ktrc -ktr -kmarktr -ktrn:1,2 -o po/keys.pot --from-code=utf-8