Lightweight alternative to Java's ResourceBundle?
Asked Answered
A

2

6

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?

Alongside answered 29/5, 2013 at 11:18 Comment(2)
I am using NLS from Eclipse, It's very lightweight and I think it servers your purpose.Assoil
@PradeepSimha a quick Google search for Maven artifacts shows that it is part of artifacts providing OSGi capabilities... Is there a more lightweight version than the ones I've found so far?Alongside
P
4

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

c10n is an interesting project too (link).

Piece answered 29/5, 2013 at 11:29 Comment(1)
Uh, it requires GNU gettext installed :/Alongside
A
1

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.

Alongside answered 29/5, 2013 at 23:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.