Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lightweight alternative to Java's ResourceBundle?

In some projects, I use the classical ResourceBundle mechanism to grab locale-dependent messages (exception messages, informational messages, whatever).

But I have a few problems with it:

  • it is too "heavyweight" for my tastes; for instance, while I only need strings, a ResourceBundle can return an Object;
  • handling of non existing keys is poor (unchecked exception instead of returning the key itself);
  • you can stack bundles, however not in the way I'd like (adding a parent using .setParent() does not make the parent searched first, but the child).

I know code can be written to overcome the two latter points; however, if there is a library out there for handling messages in a more simple way, it would be even better! Do you know of one?

like image 804
fge Avatar asked May 29 '13 11:05

fge


2 Answers

You could use GetText (link), take a look!

c10n is an interesting project too (link).

like image 187
mauretto Avatar answered Sep 24 '22 15:09

mauretto


Well, answer to self...

I have continued to google around, tried and dug into Eclipse NLS and c10n as suggested, but the "simple" criterion I was looking for was not really there.

I have therefore started my own: msg-simple.

like image 45
fge Avatar answered Sep 21 '22 15:09

fge