localeDir is not working

Pavel Bernshtam's Avatar

Pavel Bernshtam

06 Feb, 2013 07:19 AM

Hi!

I defined localeDir property to point to the 'locale' directory in the root of my project (this 'locale' directory contains 'en_US')
But it just is not working - 'locale' is not included into the swc file.

I added a property locales=['en_US], but this does not help too.

What I'm doing wrong?

Thank you!

  1. Support Staff 1 Posted by Yennick Trevels on 06 Feb, 2013 07:42 AM

    Yennick Trevels's Avatar

    Did you define it in the project that has the GradleFx plugin applied?
    Also, the path for localeDir should not start with a "/" in case you defined it like that.

  2. 2 Posted by Pavel Bernshtam on 06 Feb, 2013 07:46 AM

    Pavel Bernshtam's Avatar

    Yes, GradleFx plugin is applied (swc build finishes well, but the next swf build fails, because there is no locale properties) and locale dir is defined w/o '/'

    My "parent" build file is:


    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath group: 'org.gradlefx', name: 'gradlefx', version: '0.6.3'
        }
    }
    
    subprojects {
        apply plugin: 'gradlefx'
    
        srcDirs = ['src']
        flexHome = 'D:\\development\\adobe-flex-4.6\\'
        println "in sub projects $project.name"
    
        repositories {
            mavenRepo name: 'yoolab-releases', url: "http://projects.yoolab.org/maven/content/repositories/releases"
            mavenRepo name: 'yoolab-snapshots', url: "http://projects.yoolab.org/maven/content/repositories/snapshots"
        }
    
        localeDir = 'locale'
        locales = ['en_US']
        //resourceDirs = ['locale']
    }
    
    configure([project([':Manager']), project([':Chat'])]) {
        type = 'swf'
    
        dependencies {
            merged project (':Commons')
            merged group: 'org.as3commons', name: 'as3commons-lang', version: '0.3.6', ext: 'swc'
            merged group: 'org.as3commons', name: 'as3commons-logging', version: '2.7', ext: 'swc'
            merged group: 'org.as3commons', name: 'as3commons-reflect', version: '1.6.0', ext: 'swc'
            merged files('../Commons/lib/swiz-framework-v1.4.0.swc')
        }
    
        println "in configures $project.name"
    }
    

    My "child" build file:


    dependencies {
        external group: 'org.as3commons', name: 'as3commons-lang', version: '0.3.6', ext: 'swc'
        external group: 'org.as3commons', name: 'as3commons-logging', version: '2.7', ext: 'swc'
        external group: 'org.as3commons', name: 'as3commons-reflect', version: '1.6.0', ext: 'swc'
        external files('lib/swiz-framework-v1.4.0.swc')
    }
    
    localeDir = 'locale'
    type = 'swc'
    

    I'm checking the content of swc file using 7-zip

  3. Support Staff 3 Posted by Maxime Cowez on 06 Feb, 2013 10:05 AM

    Maxime Cowez's Avatar

    I took the liberty of formatting your code blocks to make it more readable (all code must be indented 4 spaces to be formatted correctly).

    You don't seem to be showing us the swf build scripts.
    As far as I can tell from this, there is no locale defined for the swf builds, only for the swc's, which seems to match the behaviour you describe.

  4. 4 Posted by Pavel Bernshtam on 06 Feb, 2013 10:20 AM

    Pavel Bernshtam's Avatar

    I have locale definition for all subprojects:

    subprojects {
        apply plugin: 'gradlefx'
    
        srcDirs = ['src']
        flexHome = 'D:\\development\\adobe-flex-4.6\\'
        println "in sub projects $project.name"
    
        repositories {
            mavenRepo name: 'yoolab-releases', url: "http://projects.yoolab.org/maven/content/repositories/releases"
            mavenRepo name: 'yoolab-snapshots', url: "http://projects.yoolab.org/maven/content/repositories/snapshots"
        }
    
        localeDir = 'locale'
        locales = ['en_US']
    
    }
    

    But even for swc build the locale does not compressed inside swc

  5. Support Staff 5 Posted by Maxime Cowez on 06 Feb, 2013 10:32 AM

    Maxime Cowez's Avatar

    Could you be more explicit about the folder structure of your locales?
    Does it look like:

    [project-root]
    --- src
    --- --- [code files]
    --- locale
    --- --- en_US
    --- --- --- mylocale.properties
    
  6. 6 Posted by Pavel Bernshtam on 06 Feb, 2013 10:43 AM

    Pavel Bernshtam's Avatar

    Yes, exactly. The file name is common.properties

    Can I somehow debug the plugin?

    Thank you

  7. Support Staff 7 Posted by Maxime Cowez on 06 Feb, 2013 10:59 AM

    Maxime Cowez's Avatar

    You can run any gradle command with the --info or --debug flag, but I doubt it'll give you much more information since there is no real error.

    I reread your original question; perhaps I misunderstood. Did you expect the .properties file to be included in the swc?
    This is not default behaviour: you have to explicitly add them using either resourceDirs or includeSources properties (see the docs for more info on these properties).

  8. 8 Posted by Pavel Bernshtam on 06 Feb, 2013 11:01 AM

    Pavel Bernshtam's Avatar

    So what is purpose of 'localeDir' property if I need include it explicitly?

  9. Support Staff 9 Posted by Maxime Cowez on 06 Feb, 2013 11:25 AM

    Maxime Cowez's Avatar

    The content of those properties files is embedded in a swf or swc (so that ResourceManager can find the correct translations), but the file itself is not by default packaged into a swc.

    So if you use ResourceManager inside the swc to use the translations in the properties files, there is no need to explicitly add the files to the swc. Their contents will be embedded in the swf (that's inside the swc) and ResourceManager will be able to do its job.

    However, if your properties file is located in a library, and you want an application to use the information in that file, you'll have to add the file to the swc, so that the main application can embed it into its swf.

    It's the same as with any type of asset really. If you embed an image inside a library; no need to include it in the swc. If you want to use an image from a library in an application; include the image in the swc.

  10. 10 Posted by Pavel Bernshtam on 10 Feb, 2013 09:14 AM

    Pavel Bernshtam's Avatar

    Thank you.
    Finally I solved it by
    additionalCompilerOptions << '-include-resource-bundles=common'

    May be such option should be added to the plugin?

  11. Support Staff 11 Posted by Yennick Trevels on 12 Feb, 2013 08:01 AM

    Yennick Trevels's Avatar

    include-resource-bundles is mainly used to create resource bundles though (swf's which contain localized resource bundles which can be loaded by a swf application), so while it may work I don't think it's the optimal solution.

    As for adding such an option, I'd rather document how to do this (in some kind of how-to section) instead of adding another option. Adding more build-in options put an extra layer on top of the compiler, which makes the GradleFx code more complex and more error prone. Therefore I try to keep the build-in options to a minimum.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac