12 Replies Latest reply on Jul 13, 2007 3:08 AM by mikeSibbald

    Problem using ResourceBundle

    Cheree Singal Level 1
      Hi,
      I am using .properties file in my application. I have put all the properties files under the location WEB-INF>flex>locale> app_folder. And I am using the properties file as:
      [ResourceBundle(" Properties_file_name")]
      private static var rb: ResourceBundle;

      and then rb.getString(key) in a function call.

      Everything is fine till here.
      Problem is that when I compile the mxml file, I get the error something like:
      ResourceBundle Properties_file_name not found.

      But when I compile again, it doesnt throw any error! That means after any change in the mxml file, I have to compile twice!
      Does anyone have any suggestions?
      Thanks in advance,
      Cheree
        • 1. Re: Problem using ResourceBundle
          Cheree Singal Level 1
          Not even a single response!!! I am sure many of you would have used ResouceBundles...
          • 2. Re: Problem using ResourceBundle
            cheftimo Level 2
            Hello, Cheree:

            I feel your pain. I have made several posts related to Resource Bundles and I18N/L10N. It seems not too many developers are involved in these things and the Adobe people avoid the subject like the plague. I have posted at least six times this past month but got no reaction in either the Flex General Discussion nor the FB2 forum. Through pounding cyberspace, I have learned a lot about this lately and may be able to help you.

            I am presently on the road and will be back home by Sunday February 4. If you still haven’t figured this out by the weekend, I will then have more time and places I can steer you to. In the meantime, I suggest you read this whole thread, where you will see code and other information of interest: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=582&threadid =1238407&enterthread=y. Even though the original post was about a different kind of problem; in this thread, you will see a lot of code and a URL to a blog where you will find a lot of info about this subject.

            There is one thing I can tell you right now: the locale directory you are using is NOT where your language bundles go. I don’t want to say more at this point because I am by no means an expert on this and I want to have the right information in front of me before I make any suggestions. So, post again or write to me if you still want help after the weekend.

            Good luck and best regards,

            Carlos Corredor
            carlos@timos.com

            • 3. Re: Problem using ResourceBundle
              Cheree Singal Level 1
              Hi Carlos,
              Thanks sooooo much for replying:-)
              Yes, I need ur help even now.
              I am presently going through the thread whose link you posted.

              Thanks again,
              Cheree
              • 4. Re: Problem using ResourceBundle
                Camus Miu
                i am interested in this topic too,

                and sorry i have no idea on what is it about...
                so just subscribed this thread and see if there are any updates...

                keep an eye and finger crossed =)
                • 5. Re: Problem using ResourceBundle
                  cheftimo Level 2
                  OK, Cheree, here are a couple of more things you can look at:

                  http://livedocs.macromedia.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context =LiveDocs_Book_Parts&file=l10n_076_3.html

                  Note, on the line right above “2.”:
                  The location of the locale directory is not important, but you must be able to add that location to the compiler's source path.
                  BTW, I tried running the example, but was never able to make it work.

                  Now look here:

                  http://livedocs.macromedia.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context =LiveDocs_Book_Parts&file=l10n_076_5.html

                  Immediately below the title “Properties file formats and directories”:
                  You place string properties that you want to localize in properties files in a user-created locale directory.

                  If I can help you further, just let me know; I’ll be glad to share anything I have. And, if you think of something regarding my Custom Component problem (the code in my post), tell me about it – anything will help.

                  Carlos
                  • 6. Re: Problem using ResourceBundle
                    Cheree Singal Level 1
                    Hi Carlos,
                    I am very grateful to you for being so helpful.
                    As for the first link that u gave in ur last post, I tried to make it work too but could not. I put a 'TestProperties.properties' under 'Flex Builder 2\Flex SDK 2\frameworks\locale\en_US' in my Flex Builder installation folder but got the following error:

                    Unable to resolve a class for ResourceBundle: TestProperties.

                    I also tried putting the properties file in a separate folder 'en_test' at the same level as 'en_US' , changed the locale in compiler arguments but got the same error.
                    But, if I use Websphere for building my flex files instead of FlexBuilder( meaning that I wud import flex.war in my WAS project) and put the properties file under WEB-INF>flex>locale> app_folder, then sometimes I get that error & sometimes not!(Reason why I started this topic)

                    Now for the second link, I found it a bit confusing(You may find my question silly, sorry for that )
                    Under the topic Creating a bundle class, SimpleClass returns only 1 string! Does that mean num of strings = num of such classes. I know that is completely illogical, so I definitely dint get it right. For the same reason I dint get that why is there a need of ResourceBundle subclass.
                    However, I did create my own directory for locale and placed it outside WEB-INF and gave its path in flex.config. It worked:-)
                    But I still dint get the answer to my original question.

                    And I cud not think of anything regarding your code. But if I find anything, I ll definitely let u know. I keep checking for updates in that thread.
                    • 7. Problem using ResourceBundle
                      cheftimo Level 2
                      Hello, Cheree:

                      First, please be aware of the fact that I am no expert, just a hacker, and I can tell you are way more advanced than I on this subject. I am a former restaurant chef-owner and I contracted the programming bug in the mid 90s when I decided to build my own restaurant web site, still live, timos.com (speaking of bugs, I never saw so many until I got involved in this Flex business). Until just a few years ago, I thought a menu was a list of things to eat, hence the user name ‘chefimo’.

                      So, I do not find any of your questions silly – some of my answers may be – and I am learning a lot by interacting with people like you in these forums.

                      The way I see it, all those .properties files in ‘Flex Builder 2\Flex SDK 2\frameworks\locale\’ contain the (global?) properties for a given locale – the ‘en_US’ folder is the default and the only one that comes with the SDK; you have to create one of those for each locale or this will not work. I guess these folders are where the compiler looks. In the compiler arguments, if you say ‘-locale fr_FR’ and a ‘fr-FR’ folder is not there, you will see the error you are getting. Using my case as an example, I made a copy of the ‘en_US’ folder and named it “es_CO” (Spanish, Colombia). When I get all this working right, I’ll take the time to translate the key values.

                      I hope this helps you.

                      Re what you call “the second link”: I could not find “Creating a bundle class” in any of the links I posted, so I was not able to figure out what you are referring to.

                      BTW, for you and anyone else who works with resource bundles, here is a great Resource Bundle Manager:
                      http://www-306.ibm.com/software/globalization/icu/rbmanager.jsp; it’s a Java application called “RB Manager” that comes with its own tutorial and it’s FREE!

                      Carlos
                      • 8. Re: Problem using ResourceBundle
                        Cheree Singal Level 1
                        Hi Carlos,
                        First of all, sorry for not replying for past 2 days...
                        Next, sorry for the wrong reference of the link. The link I was talking about is http://livedocs.macromedia.com/flex/201/html/l10n_076_4.html
                        This is given in the second link that you sent:-)

                        Carlos, I am already using a separate locale folder for my app and mentioned its path in the flex-config.xml. If the compiler were not finding my properties files, then it shouldn't have been able to compile my files at all but presently, as I said, it compiles sometimes & sometimes not!

                        Thanks for attending to my questions so patiently. Now, I have begun to have a feeling that this a bug. Perhaps, I should raise a ticket with Adobe people.

                        If you find time, please go through the link I gave. May be you can help me (rather I can bug you) with that too.

                        Thanks ton,
                        Cheree
                        • 9. Re: Problem using ResourceBundle
                          Cheree Singal Level 1
                          Hi Carlos,
                          First of all, sorry for not replying for past 2 days...
                          Next, sorry for the wrong reference of the link. The link I was talking about is http://livedocs.macromedia.com/flex/201/html/l10n_076_4.html
                          This is given in the second link that you sent:-)

                          Carlos, I am already using a separate locale folder for my app and mentioned its path in the flex-config.xml. If the compiler were not finding my properties files, then it shouldn't have been able to compile my files at all but presently, as I said, it compiles sometimes & sometimes not!

                          Thanks for attending to my questions so patiently. Now, I have begun to have a feeling that this a bug. Perhaps, I should raise a ticket with Adobe people.

                          If you find time, please go through the link I gave. May be you can help me (rather I can bug you) with that too.

                          Thanks ton,
                          Cheree
                          • 10. Re: Problem using ResourceBundle
                            Cheree Singal Level 1
                            Oops, I submitted my reply twice!!!
                            • 11. Re: Problem using ResourceBundle
                              cheftimo Level 2
                              Dear Cheree:

                              When I initially cited those two links, it was merely to point out the fact that you had to create your own ‘locale’ folder instead of using ‘Flex SDK 2\frameworks\locale’. I have previously looked at this URL you are now mentioning (which is not one of the two I cited, those were ‘…_076_3.html’ and ‘…_076_5.html’), but found nothing there I could apply to my situation and, frankly, I don’t yet understand some of the stuff in there; it may be a while before I get to the point where I need that material.

                              In my case, all I wanted to do was to be able to generate one SWF for each language – and I have done that without messing with ‘flex-config.xml’ or doing anything other than changing the –locale compiler argument. This business of having to compile twice sounds very strange.

                              Besides creating my own ‘locale’ folder, the key to solving my problem was also making that new ‘Flex SDK 2\frameworks\locale\es_CO’ folder, as I mentioned in my previous post.

                              You can see a little more about that in the comments here, bottom of the page: http://jeff.mxdj.com/internationalizing_flex_2_apps_pt_2.htm. This is the blog of Jeff Tapper, one of the authors of Flex 2 Training from the Source. You may want to post some of your issues here; it looks like this gentleman really knows what he’s talking about.

                              Anyway, just out of curiosity, are you trying to do more that just localizing language and date/currency formats? Do you have a URL I can look at? I am thinking about this only as a possible sample/source of information.

                              I wish I could be of more help. Please let me know if you find out anything new related to this subject.

                              Carlos – carlos@timos.com