ibauersachs / dnssecjava

A DNSSEC validating stub resolver for Java.
Other
43 stars 15 forks source link

Provide alternative to the resource bundle mechanism #7

Closed schildbach closed 8 years ago

schildbach commented 8 years ago

Dnssecjava pulls strings from a messages.properties. Unfortunately, Android does not have this mechanism. This results in an exception whenever R.get() is called, e.g.:

Caused by: java.util.MissingResourceException: Can't find resource for bundle 'messages_en_US', key ''
at java.util.ResourceBundle.missingResourceException(ResourceBundle.java:238)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:230)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:139)
at org.jitsi.dnssec.R.<clinit>(R.java:20)
schildbach commented 8 years ago

@techguy613 You might want to have a look at this.

ibauersachs commented 8 years ago

Any suggestions on how you'd like to handle this instead?

schildbach commented 8 years ago

I think I would simply inline all the strings into the source code. If I understand it right, these are all exception messages which should not be translated anyway. So what's the resource bundle indirection good for?

Another idea would be a static setter that could be used by Android apps to set the resource bundle in your R class manually. Because Android actually can read resource bundles, it just doesn't support reading them from the classpath like you do.

ibauersachs commented 8 years ago

Hm, these were meant to be an explanation why a validation failed.

The setter is a good alternative, and as a fallback, returning the key (formatted like in the unit tests: key:param1:...:paramN)

schildbach commented 8 years ago

Ah, that fallback would be perfect. Even without the setter.

techguy613 commented 8 years ago

Hey all, the setter sounds good to me. Should I take a crack at it or would you (@ibauersachs) like to make the change yourself?

ibauersachs commented 8 years ago

Some help would be very welcome :-)