In Python/C++, I normally use _("string") for i18n string text.
for Java, I use bundle.getString("string"). Obviously, it is uglier than Python/C++.
How to write such code shorter?
Create your own method:
public String _(String key){
return bundle.getString(key);
}
Or something similar. Underscore is a valid method name in Java. Of course, you can use any other single character, if you prefer, say l
like localize.
So, now you can call it the same way as in Python.
Thats the way Java is, you can call it ugly, though.
I would pretty much stick with the Java convention and use the bundle.getString(...)
version. :)
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