When building localized Flex applications with ResourceBundle there are a few tricks you may not be aware of which can come in handy should you need them.
I have had quite a few people ask how multiline values can be specified in a properties file. This is a pretty common question and luckily the answer is very simple: backslash (\).
For example, suppose you have a properties file which contains a string resource with a really long value, like a paragraph. Typically the property value will just be one really long String on one line. However you can use the backslash (\) character to continue the value on multiple lines in order to make the properties file more legible, such as in the following example:
1 2 3 4 5 6 7 8 9 10 11 | title = Welcome message = Lorem ipsum dolor sit amet, consectetur elit, \ sed do eiusmod tempor incididunt ut labore et dolore magna \ aliqua. Ut enim ad minim veniam, quis nostrud exercitation \ ullamco laboris nisi ut aliquip ex ea commodo consequat. \ Duis aute irure dolor in reprehenderit in voluptate velit \ esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\ occaecat cupidatat non proident, sunt in culpa qui officia \ deserunt mollit anim id est laborum. |
So if you have properties with very long values remember to use backslash (\) to help clean up your resources.
Cool, didn’t know that 🙂
But do you know how to add newline? \n doesn’t seem to do the trick, Flex Builder gives a warning that it will be ignored.
What version of Flex Builder are you using? In Flex 3 you should be able to specify values which contain \n with out compiler warnings.
nice! didn’t know that too, thanks 🙂