9 Replies Latest reply on Nov 12, 2008 12:36 PM by Ivan B

    Seam Resource Bundle

    Andrew A Newbie

      Hi all,


      Appreciate the excellent work being done with Seam and this Wiki site is impressive.


      Quick question.  As java resource property files are limited to a certain range of character sets, are there any plans to extend the seam resource bundle to xml resource files to allow full i18n?  If so, when would we expect this to be roughly happening by? 


      I'm currently implementing my own custom resource bundle control to handle xml resource files, but if I'm in a framework, my preference is to use what is available in the ecosystem rather than diverging.


      I have done a number of searches related to the question, and the closest I found was a discussion in this forum on Chinese character sets within xhtml facelets, but not covering resource bundles.


      Thanks,


      Andy

        • 1. Re: Seam Resource Bundle
          Christian Bauer Master

          As java resource property files are limited to a certain range of character sets,


          They are not, you can use any correctly defined UTF character in a Java property file or in a message bundle. I mean, it would be a bit surprising if a text format for translating texts wouldn't support that, no?



          • 2. Re: Seam Resource Bundle
            Andrew A Newbie

            Thanks for the reply,


            In answer to your response, yes and no.


            Java will interpret a message bundle with the default encoding of the OS.  So the characters represented are still limited to a subset.  Secondly, and in contradiction to the previous statement, it is expected that the files are created in ASCII, and any non-ASCII characters are written as hex escape sequences.  This allows the full UTF character set to be supported, but does not lend itself well to raw editing without an appropriate tool, especially for more than simple sentences.


            See: http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/
            and
            http://java.sun.com/javase/technologies/core/basic/intl/techart.jsp


            The introduction of xml resource files were introduced to address this very issue, as the encoding is declared in the document, and other than escaping xml characters, no escaping is necessary. 


            However, it would appear that the Seam community do not see the need to consider this functionality, which I have no issue with.  It simply means that I do not need to keep an eye on future developments in this space and can continue with my own solution.


            Cheers,


            Andy

            • 3. Re: Seam Resource Bundle
              Andrew A Newbie

              I just reread my message and thought it was a little ambiguous.


              x.java resource bundles are interpreted as per the OS encoding.  To use them as unicode, you need to specify to the compiler the encoding of each of your resource files.


              Property files are restricted to ASCII and escape sequences, which is the contradiction in the previous message.  I know that in practice, I have gotten away with non-ASCII characters in my resource bundles, and they have displayed correctly, but as Sun are saying that non-ASCII are not supported, I don't want to hit the occasion when I do use a character that does cause failure.


              Anyway, everyone has different preferences, and I prefer xml resource files to property text resource files.


              Cheers,


              Andy

              • 4. Re: Seam Resource Bundle
                mars1412 Apprentice

                AFAIK, you must use ISO-8859-1 in java properties files:



                The load and store methods load and store properties in a simple line-oriented format specified below. This format uses the ISO 8859-1 character encoding.

                from java.util.Properties


                if you have properties fiels that are using other character encodings, you can convert them to ISO-8859-1 with native2ascii tool

                • 5. Re: Seam Resource Bundle
                  Christian Bauer Master

                  Well, that is what I said: correctly defined UTF characters. The correct definition uses an escape syntax.


                  • 6. Re: Seam Resource Bundle
                    Andrew A Newbie

                    Hmmmm.  If it is not such an issue, then why is the French resource file that is generated from seam-gen not correctly escaped for the non-ascii values?  Both the German and Bulgarian resource files seem to be correctly escaped. Ensuring that these files are correctly escaped is simply problematic.


                    I have just been working with an Arabic resource property file where every character other than the inserted variables are non-ascii so are escaped - just like the Bulgarian file from seam-gen.  It's fine to get the original translation and escape it, but then sending an escaped file to a translator for updates is not really an option, and it is cumbersome though admittedly not difficult to keep a pre and post version or to run the ascii2native tool to return it back to its original so that a translator can do their stuff.


                    As per the original post, technically a Java property file can only support ascii characters which is a limited range.  Or as Marin pointed out - the ISO-8859-1 character set.  Escaping character codes is a work around to this limitation and is not in my mind the same as correctly defined UTF, even if you achieve the same ends using escape sequences. But that is a case of semantics.


                    As I said previously, it is a personal preference thing, and I have no issues with Seams stance.  My personal preference just being with xml where a translator with no convenient Java IDE to edit Java property files can simply type away in any XML editor or unicode text editor and the results can be seen by anybody at every stage with no additional processing, and ongoing maintenance is no issue.


                    Anyway, this thread is getting silly, so I will stop here - lol


                    Cheers,


                    Andy

                    • 7. Re: Seam Resource Bundle
                      mars1412 Apprentice

                      I don't think the thread is silly.


                      I think what you want is a valid feature request, because it would certainly help developers of international sites.


                      • 8. Re: Seam Resource Bundle
                        krishna Garapati Newbie

                        ResourceBundle bundle = SeamResourceBundle.getBundle();
                        String name = bundle.getString("name");
                        int age = Integer.parseInt(bundle.getString("age"));

                        Like this we can get the values from the properties file in seam.

                        • 9. Re: Seam Resource Bundle
                          Ivan B Novice

                          I don't understand why we can't use -Dfile.encoding=UTF8 and keep message.properties in normal UTF8 charset, without hassling with native2ascii.