2 Replies Latest reply on Mar 20, 2006 3:49 PM by treespace

    ResourceBundle considered harmful

      Resource bundles do not work with XML or RDBMs which is very telling IMO. Supports my contention that I8N with resource bundles should be renamed SteamingResourcePile [audible laughter from crowd].

      It seems infinitely simpler to just create a message file for each language, then load them all in to the session context as a enumerated map. You can match every message you load against an enum value so JBoss won't even start-up if there' san error. In your code you can use the enums exclusively, and the strings on jsp or jspx files.

      In other words, resource bundless seem like a well-intentioned but misguided attempt to I8N when all we really needed wa a Map populated from your own choice of data souce.



        • 1. Re: ResourceBundle considered harmful

          Resource Bundle Redux

          Enumerate messages:

          enum Messages
          {
          UserNameInUser,
          ... more ...
          }

          Load this xml in to Map<Message, Map<Locale, String>>




          User name already in use
          blah blah blah
          daka daka daka
          ... more ...


          ... more messages ...



          This strategy puts all the token translations under one roof. The code uses the enumerated tokens for safety:

          messages.get(token).get(locale)

          Think this suggestion will be valuable to those doing I8N but think that ResourceBundle solution is sub-optimal, so to speak.

          • 2. Re: ResourceBundle considered harmful

            Resource Bundle Redux (oops, forgot code block)

            Enumerate messages:

            enum Messages
            {
             UserNameInUser,
             ... more ...
            }
            


            Load this xml in to Map< Message, Map< Locale, String > >

            <messages>
            
             <msg token="UserNameInUse">
             <en>User name already in use</en>
             <fr>blah blah blah</fr>
             <ar>daka daka daka</ar>
             ... more ...
             </msg>
            
             ... more messages ...
            
            </messages>
            


            This strategy puts all the token translations under one roof. The code uses the enumerated tokens for safety:

            messages.get(token).get(locale)

            Think this suggestion will be valuable to those doing I8N but think that ResourceBundle solution is sub-optimal, so to speak.