5 Replies Latest reply on May 11, 2007 4:14 PM by cheftimo

    Special characters (e.g. quotation marks) in resource bundles

    BMorearty
      When I put special characters such as quotation marks in resource bundles, I get a compile-time error when the generated source is compiled. How do I insert special characters?

      The error is:
      Syntax error: expecting rightbrace before Name. [Generated code (use -keep to save): Path: RegistrationForm_properties, Line: 18, Column: 42]

      I've tried the following in the .properties file. They all get the same error because they all generate the same ActionScript:

      personname="Name"
      personname=\"Name\"
      personname=\u0022Name\u0022

      Here's the generated actionscript for all three (notice too many quotes around Name):

      properties["personname"] = ""Name"";
        • 1. Re: Special characters (e.g. quotation marks) in resource bundles
          cheftimo Level 2
          Hello, BMorearty -

          In .properties files, key values are NOT sorrounded by quotes or anything else. Example:

          for xxxen_US.properties - personname=name
          for xxxes_CO.properties - personname=nombre

          But you can use the special characters within the key values with no problems.

          Carlos
          • 2. Re: Special characters (e.g. quotation marks) in resource bundles
            BMorearty Level 1
            quote:

            But you can use the special characters within the key values with no problems.


            Thanks cheftimo, but what am I doing wrong? When I want to put special characters (quotation marks) in my strings I get the errors I mentioned above.
            • 3. Re: Special characters (e.g. quotation marks) in resource bundles
              cheftimo Level 2
              Hello, BMorearty:

              In your .properties files, you use the character entity for a special character, not the character itself. Take a look at this little project http://www.timos.com/coiBI/coinoniaBI.html, which I have been playing with; ViewSource is enabled, so you can see all the files, including the Resource Bundles (.properties files), which are in the ‘locales’ folder. At this point, this is a study project and it’s somewaht messed-up, but viewing the source code may be of help to you.

              If you work with .properties files, I strongly recommend that you use RBManager to create them in the proper format. You can get it here: http://www-306.ibm.com/software/globalization/icu/rbmanager.jsp. With its quirks and bugs, it’s one of my favorite applications to work with – it comes with a tutorial you can do in no time, and it’s free.

              On and off as time permits, I have been playing with the above-mentioned project, trying to make it so you can switch languages at runtime, which Flex does not natively support, because I just hate the idea of having a separate SWF for each language. I have been having a hell of a time getting components to talk each other. If this is a subject that interests you, see this thread: [ http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid =1246251&highlight_key=y. I don’t even know if the project you are working on is multilingual, but if this subject interests you and you want to participate in the fray, post a reply to that thread, not to the one we are in now.

              I hope you have the time to give us your ideas on this.

              Best regards,

              Carlos
              • 4. Re: Special characters (e.g. quotation marks) in resource bundles
                BMorearty Level 1
                Thanks, Carlos. That's helpful but unfortunately it still doesn't solve my problem. I did not know about the RBManager application. It certainly seems useful for maintaining .properties files. (Too bad it always uses Unix line-endings even when running on Windows, but I can live with that.)

                But when I use a double-quotation mark ( " ) in a property, RBManager just inserts it as a literal quotation mark. This still results in the same compile-time error I described before.

                (Your project at http://www.timos.com/coiBI/coinoniaBI.html escapes quotation marks using ", but that only works when the resource is HTML text. For plain text, " does not work.)

                If the standard .properties format is supposed to allow quotation marks, I'm beginning to think it's a bug in the Flex compiler that it fails to compile.
                • 5. Re: Special characters (e.g. quotation marks) in resource bundles
                  cheftimo Level 2
                  Hi BM:

                  I don’t think this is so much a bug problem, as crappy implementation of this RB business by Adobe. Flex removes the double quotes because they “cannot be in a .properties file”, or something liked that, according to the error you get in the Problems window. But that’s a Flex thing, not a problem with the files that RBManager spits out; those are Java bundles and that’s the way they work. Look at this page: http://www.dircolombia.com/dc/quienesSomos.cfm - you’ll see double quotes and asterisks all over the place, as you will in the rest of that site, which uses the bundles without having to do anything special, because ColdFusion has real support for these things.

                  It looks to me that the only problem character is the double quote; none of the other special characters generate errors. So use ‘htmlText’ instead of ‘text’. If you think about it, it IS ‘htmlText’, just with no tags; just replace all double quotes with ‘"’ and voilá, all cool.

                  I understand Flex 3 is going to have support for runtime locale switching; let’s hope they do a good job of updating all these Mickey Mouse things that are there presently.

                  In the sample site I sent you previously, I removed all the HTML tags but not the ‘"’ entities, set widths for all the text controls (what I should have done from the beginning), and left the ‘htmlText’ text tag attributes alone - it actually looks better now.

                  If you think of any ideas about the components communicating issue (that I mentioned in the previous post), please let me know.

                  Have fun,

                  Carlos