Flex: Unable To Open Locale

When you’re working with locales in Flex, you would put in the following code in you ant build file:

<mxmlc>
<locale>it_IT</locale>
<source-path path-element=”locale/it_IT”/>
<include-resource-bundles>formlabels</include-resource-bundles> <source-path path-element=”${FLEX_HOME}/frameworks”/> <output>bin/formlabels_it_IT.swf</output>
</mxmlc>

Then when you get a puzzling error:

[mxmlc] C:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\frameworks\flex-config.xml(75): Error: unable to open ‘locale/it_IT’

But don’t you have that exact directory? Well, apparently Flex is actually looking for the it_IT folder in its locale folder. The solutions is to just create an empty it_IT folder:

<macrodef name=”compileLocale” description=”Compiles the Resource package for the given locale”>
<attribute name=”locale” default=”en_US”/>
<attribute name=”outputdir” default=”bin-debug”/>
<sequential>
<!– Create the Flex Home directory for the language in question. This is necessary to compensate for a bug in pre-3.2 releases of mxmlc. –>
<mkdir dir=”${FLEX_HOME}/frameworks/locale/@{locale}”/>

<!– Invoke MXMLC –> <mxmlc> <locale>@{locale}</locale> <source-path path-element=”locale/{locale}”/> <include-resource-bundles>formlabels</include-resource-bundles> <source-path path-element=”${FLEX_HOME}/frameworks”/> <output>@{outputdir}/formlabels_@{locale}.swf</output>
</mxmlc>
</sequential>
</macrodef>

Thanks to Adobe Cookbooks for the solution!