javagettextxgettext

xgettext detects false positives due to java.sql.ResultSet::getString


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.


Solution

  • 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:

    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