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

https://stackoverflow.com/questions/79639929/xgettext-detects-false-positives-due-to-java-sql-resultsetgetstring 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.
14 Replies
JavaBot
JavaBot7mo ago
This post has been reserved for your question.
Hey @<Tim>! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
<Tim>
<Tim>OP7mo ago
I'm so lost here... can't be that I cannot use a method called getString anywhere if I want to use i18n
JavaBot
JavaBot7mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
dan1st
dan1st7mo ago
sry for the late response (but it's better than no response) Tools like that can't really differentiate between these things (except you create a whitelist which has a lot of other issues). I can tell you how it works in Eclipse (if you enable that): - It assumes all string literals should be localized by default - You can add a // NON-NLS-1 comment which means "the first string literal in this line is ok as-is - also works with multiple literals in the same line, e.g. NON-NLS-2 - you can errors for missing localization idk whether that's possible with xgettext though I wrote two comments on your SO question with additional information
<Tim>
<Tim>OP7mo ago
Thanks for the response, I also saw your comments on so :) oof that sounds way worse though 😅 I have a lot of string literals, but only a fraction of them are exposed to the user. And I still need to wrap them in i18n.tr() calls, so it would result in me having to touch every single string in a project with hundreds of files.
JavaBot
JavaBot7mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
<Tim>
<Tim>OP7mo ago
Do you happen to know any other tools for internationalization? (I cannot force everyone else to switch to eclipse and tbh I don't want to myself 😅 but anything else that runs on linux is fine)
dan1st
dan1st7mo ago
Maybe only do it for a given package that contains UI-related stuff? And in Eclipse, these references are translated to variable accesses which are automatically loaded from a properties file, e.g. display("Hello World"); turns to display(Messages.helloWorld); or something like that
<Tim>
<Tim>OP7mo ago
well apperently they just plainly scan for keywords and getString is one of them... but it sounds like it can be disabled 👀
No description
<Tim>
<Tim>OP7mo ago
hahaha you assume we have proper layers and not some random JSP pages directly accessing repositories or services just forwarding error messages to the next layer xd yoooo wow, I just had to add -k to the command... Specifying your own keywords just adds them to the spec, adding the empty string as keyword removes all default keywords 💀
dan1st
dan1st7mo ago
ah ok
<Tim>
<Tim>OP7mo ago
with that out of the way, I just need the I18nFactory to actually find my resource bundles 💀
JavaBot
JavaBot7mo ago
Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click I'm done here. Close this post!.
JavaBot
JavaBot7mo ago
Post Closed
This post has been closed by <@330307656105328640>.

Did you find this page helpful?