Announcement Announcement Module
Collapse
No announcement yet.
Has someone thought of XML Resouce Bundles? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Has someone thought of XML Resouce Bundles?

    Hi All,

    how do you internationalize your JSPs? I'm currently going with two approaches:

    1: Messages, Labels, etc. in .properties resouce bundles
    2: JSPs that contain more text, with embedded hyperlinks and the like are in language specific JSPs.

    I don't like the overhead of the language specific JSPs. It's just a mess to maintain if there a more than a handful. Also, I don't like to include hundreds of JPS-fragments too. Is there a better approach?

    I thought about XML resource bundles. Basically just like the property-resoucebundels but with an XML syntax and therefore being able to use all the XML features like entities (not char entities) and the like. i.e. something like this:

    Code:
     
    messages_en.xml
    <properties>
        <property key="my.label">Some Label</property>
        <property key="my.long text">
         A  long text with .... maybe with a hyperlink whatever...
        </property>
    </properties>
    Behaviour, naming, resolution within spring etc. exactly like the regular ResourceBundles. Did someone tried to implement something like it? Would there be a need out there for it?

    I think it would be great to have something like that in spring.

    -andi

  • #2
    I had similar problems and I have written a MessageSource implementation that reads its messages from a database table (I can post the code if someone is interested).
    The idea was to give end users the ability to change/add messages while the application is up and running. But soon I realized that messages are more or less part of the application and should be upgraded in sync with the source code (and hence belong in CVS).
    Well, I am still not sure, because that would make the developers responsible for (or at least involved with) maintaining all those translations.

    I recently discoverd TMX (http://www.lisa.org/tmx/) an open standard for exchanging translations, based on xml.
    Would be nice if there was a Spring MessageSource that could read tmx files. See also http://tmxjavabridge.sourceforge.net/.

    Maarten

    Comment


    • #3
      Hi Maarten,

      that sounds interesting. I just checked the TMX sources. The XML files are of a, uhmmm, very technical syntax (put friendly ).

      http://www.tecnick.com/public/code/c...rticle_tmx#tmx

      I guess your brain gets mushy if you would edit those files in a text editor But the idea is good though. Exactly what i was looking for. It seems to be some kind of standard, so it would be _very_ nice to have Spring supporting TMX Bundles.

      Putting als the messages in the database is not an option for me (at least for the project i'm doing). The messages are too application specific (Exception messages, and the like). Mostly standard ResouceBundles are fine, but for the JSPs it would be nice to have those XMLs.

      It depends though. I've learnd that everything the user can change causes problems. So if it's not a requirement for you application that the user can change message strings, I'd not let him. This also gives you full controll for problem analyzing. If someone calls your support and asks "We have a problem, the application tells me this and that" it can be a user changed message. So you would have to add error codes that are displayed along all messages to identify the message. And i don't think it's nice to have a integer attached to each string in your app.

      But again, i think it depends on the specific application. What kind of app is yours?

      -andi

      Comment


      • #4
        JDK 5.0 supports XML Properties... Very cool.


        [url]http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html[/code]

        Too bad that the PropertiesResourceBundle does not

        Comment

        Working...
        X