[Note: I recently presented at 360Flex San Jose on the topic of localization (L10N). During that session, several questions were asked that I did not have the answers to. Over the next few months I will be attempting to answer all of those questions and more.]
In Flex, resource bundles are used to provide localization features — that is, the ability for your application to provide the user with a different language and regional preference — to your applications. All Flex applications start up with US English as the base language here in the United States of America. Even Flex Builder's default compiler options includes "-locale en_US" making it possible for you to begin localizing your application.
The "gotcha" that hit me the first time I created a resource bundle for localization in a Flex application was the file encoding. The default file encoding setting in Flex Builder (Eclipse) is ISO-8859-1, which if you use is ok for English, but if you choose to copy this file and use it for someone to translate your English text to, say, Spanish it could cause you some problems. For instance, I had a main.properties file that I was translating line by line with Google Translate (I know, lame) from English to Spanish. When I had completed the process and saved the new file, boy was I disappointed. All the special characters that Spanish uses were replaced by triangles with question marks. Converting that ISO-8859-1 file to UTF-8 with the tools at hand made things worse. My choice at the time was to start over from scratch making certain that my English file was UTF-8 and then all my future copies would also be UTF-8.
And, of course, when I told this sad story during my presentation at 360Flex San Jose an attendee asked "Isn't there a preference setting for that inside Flex Builder?" My response at the time was, "I'm sure there is but I have not found it." But I have now!
To get to that preference setting in Flex Builder (stand alone), select "Window" > "Preferences..." and the Preferences dialog box will appear. In the left side tree open "General" and select "Content Types." The right side will have a new tree in the top. Open "Text" and select "Java Properties" and the bottom of the right side will show the File Assiociations and Default Encoding settings. You'll notice that the Default Encoding is set at ISO-8859-1. Merely change the text in that field to "UTF-8" and you'll be done. From this point forward, *.properties files that Flex Builder creates will be encoded as UTF-8.
You can also change this setting on a per-workspace level (not that I could think of a good reason to do it that way). With your Preferences dialog open and "General" selected in the left side tree, select "Workspace." You will see an option labeled "Text File Encoding". Select the "Other" radio button and use the combo box to select the encoding you desire.
Please let me know in the comments if you have a problem with these instructions in your environment.
Comments (5) | Print | Send | del.icio.us | Digg It! | Linking Blogs