incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Om <bigosma...@gmail.com>
Subject Re: Asset / i18n resource management improvements
Date Tue, 12 Jun 2012 19:07:45 GMT
One feature I would like added is to assign a master resource file.  I have
had scenarios where I start out with en_US and get other locales created by
manually copying a bundle or use the copylocale util.  But once I start
adding new strings to en_US, the other bundles have to be manually kept in
sync.  This becomes too tedious very quickly.

My proposal, is to at least show compiler warnings if other locales dont
have matching strings for each entry in the 'master' bundle.

And master bundle is something we can set as a compiler option.

Thoughts?

On Tue, Jun 12, 2012 at 11:47 AM, Om <bigosmallm@gmail.com> wrote:

> Dirk,
>
> I think this is a fantastic idea.  I would love to help out.  Every time I
> work with resource bundles, I keep having similar thoughts.  I never took a
> chance to write it out so clearly like you have done.
>
> What I dont get is why we would need a FB/Eclipse plugin if we manage to
> make these changes to the compiler.  As you example points out, a valid
> class would be created in the src path.  This would take care of the
> auto-complete requirements, right?  All IDEs should be able to work with
> it.
>
> Look into FTML for that, it's already built in native for Flex... and much
>> more.
>>
>
> Rich,
>
> Can you please elaborate?  Googling "FTML for Flex" is not yielding any
> relevant results.
>
> Thanks,
> Om
>
>
> On Tue, Jun 12, 2012 at 6:27 AM, Dirk Eismann <bortsen@googlemail.com>wrote:
>
>> I'm currently experimenting on how to improve resource management in
>> future Apache Flex versions.
>>
>> It all started when I wanted to mimic the Android IDE (ADT) behavior
>> where ADT automatically creates a class R with static accessors for
>> project resources. E.g. a default Android project has a /src and a
>> /res folder. If you put a foo.jpg into the /res/drawable folder, the
>> ADT creates R.drawable.foo that can be referred to in your code (where
>> foo is actually a int that's used for resource loading at runtime,
>> more info here [1])
>>
>> So I jumped in and created a plugin for Eclipse / Flash Builder that
>> does the same by autogenerating a R.as class with static fields that
>> are used to [Embed] image assets. As soon as you drop images into
>> /res/images inside of a FB project, the R.as class gets updated etc.
>> This happens before the mxmlc compiler starts a compilation run, so
>> you can do this in your code
>>
>> <s:Image source="{R.images.foo}"/>
>>
>> This works pretty nicely, although as of now it's only working in FB /
>> Eclipse, not with CLI builds (yet) [2]
>>
>> The next thing on my list was to improve ResourceBundle / i18n
>> handling a bit. I'm too tired to use ResourceManager.getInstance or
>> resourceManager.getString("foo", "bar") all the way which is annoying
>> to type and error prone. Would be much nicer to have code hinting here
>> as well. Ideally, I'd like to do
>>
>>  <s:Label text="{R.bundles.myBundle.foo}"/>
>>
>> which would get the value of the key "foo" from ResourceBundle
>> "myBundle". Another way would be to have a class B (for Bundles) which
>> is even less typing
>>
>>  <s:Label text="{B.myBundle.foo}"/>
>>
>> or something like this.The general idea is to avoid too much typing
>> and taking advantage of what an IDE offers you in terms of code
>> hinting.
>>
>> The nice side effect of this "less code to type" approach is that you
>> get "less errors that will happen" as well since all asset / resource
>> accesses are checked by the compiler.
>>
>> Currently I have a few ideas and things I would like to implement:
>>
>> 1) envision how a default project layout for a Flex project could look
>> like. As of now a default project has a /src folder. Maybe we can
>> agree that it's a good idea to put place assets into an /assets or
>> /resources folder. This would be the default path that is used for
>> automatic asset / bundle transformation and code generation
>>
>> 2) create a compiler extension for mxmlc or a patched version of the
>> flex2.compiler.i18n.I18nCompiler that automatically generates / emits
>> code for the R class and modifying the code that gets generated for
>> the mx.resource.ResourceBundle sublasses without breaking backwards
>> compatibility (so you can still do @Resource or
>> resourceManager.getString())
>>
>> 3) create a Ecipse / FB plugin that uses the "rules" from 1) and the
>> compiler extension from 2) to streamline this in the IDE (as of now I
>> am an FB / Eclipse user so I can only provide Elcipse plugin know-how,
>> I have not yet done anything with IntelliJ or any other Flex IDE)
>>
>> So... what do you think? I would also like to know what other people
>> have in mind concerning asset / resource bundle management, maybe we
>> can team up?
>>
>> Cheers,
>> Dirk.
>>
>> [1] http://developer.android.com/guide/topics/resources/index.html
>> [2] https://plus.google.com/u/0/111304077092175055051/posts/St8TkR4DFLY
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message