views:

212

answers:

1

I've seen a number of examples, e.g. here, where people are including locale resource bundles by referencing the locale attribute in the element. For some reason this doesn't work for me. Here's what I have for the task:

<compc output="${deploy.dir}/myfrmwrk.swc" locale="en_US">
    <source-path path-element="${basedir}/src/main/flex"/>
    <include-sources dir="${basedir}/src/main/flex" includes="*" />
    <include-libraries file="${basedir}/libs"/>
    <compiler.external-library-path dir="${FLEX_HOME}/frameworks/libs/player/9" append="true">
        <include name="playerglobal.swc"/>
    </compiler.external-library-path>
    <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
        <include name="libs"/>
        <include name="locale/${locale}"/>
    </compiler.library-path>
    <load-config filename="${basedir}/fb3config.xml" />
</compc>

This fails with a bunch of errors of the form:

[compc] Error: could not find source for resource bundle ...

I can make it build with this one change:

<include name="locale/en_US"/>

The configuration file generated by Flex Builder 3 actually renders this as "locale/{locale}" (notice the $ is missing). I've tried that as well with the same (failing) results.

For now, I'm doing OK directly injecting en_US as we won't be doing localization bundles for quite some time, but I will eventually need to get this working. Also, it bugs me that I can't make it work the way that it SHOULD work!

+1  A: 

I think the problem here is that ${locale} is interpreted by ant as a property, rather than a string literal to pass to the compc task. What I mean is that ant sees ${locale} and thinks that you want to substitute the value of the property locale which is (supposedly) defined in your build file. Of course, this isn't what you want at all, and things break miserably because of it.

The way I've done things in my build files is to remove the $ prefix and everything seems to work as expected. So your example would look something like this:

<compc output="${deploy.dir}/myfrmwrk.swc" locale="en_US">
    <source-path path-element="${basedir}/src/main/flex"/>
    <include-sources dir="${basedir}/src/main/flex" includes="*" />
    <include-libraries file="${basedir}/libs"/>
    <compiler.external-library-path dir="${FLEX_HOME}/frameworks/libs/player/9" append="true">
        <include name="playerglobal.swc"/>
    </compiler.external-library-path>
    <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
        <include name="libs"/>
        <!-- Ditch the dollar sign and things should work! -->
        <include name="locale/{locale}"/>
    </compiler.library-path>
    <load-config filename="${basedir}/fb3config.xml" />
</compc>
Dan