How to compile locales / resource bundles?

67 views
Skip to first unread message

mosesoak

unread,
Feb 10, 2012, 1:42:08 PM2/10/12
to ProjectSprouts
I'm doing custom locale swf compilation, which I can do fine via the
command line by doing these steps:

• run the copylocale utility from the mxmlc bin directory (one time
only)
• run mxmlc with -locale, -include-resource-bundles, -source-path+=, -
allow-source-path-overlap, -output


I'd love to automate this in sprouts but have the following questions:

1. How do I tell Sprouts to use the exact SDK I want to compile to.
Currently that is the 4.1 SDK with the security patch released by
Adobe (flex_sdk_4.1.0.16076A)?

2. How do I tell Sprouts to run copylocale one time only and specify
the from and to params?

3. Sprouts rejects the variable include_resource_bundles in its mxmlc
framework.

(I don't want to use the list file option. The docs under source_path
say "The source path is also used as the search path for the component
compiler‘s include-classes and include-resource-bundles options" but I
get "undefined method `include_resource_bundles' for #<FlashSDK::MXMLC:
0x10225ee98>".)

4. Sprouts chokes when I provide only a source_path ("Error: a target
file must be specified")

Any help much appreciated,
Thanks!!! :-)

mosesoak

unread,
Feb 13, 2012, 12:37:01 PM2/13/12
to ProjectSprouts
I've gotten a rake task that works on this which I'll share here.
(Thanks again to Alan Pinstein for showing me how to dynamically
generate rake tasks within other tasks. Cool trick.)

Luke, I had to add include_resource_bundles to mxmlc to make this work
- you currently only have it in compc.

The task first deletes the locale swfs from all 3 directories ( bin-
debug, html-template, bin-release + /locale), compiles to the first
one, then copies to the other 2.

The one last piece would be a way to use sprouts to run copylocale
conditionally when the locale doesn't exist.

I'm posting this to get feedback - both on the copylocale step and
also on making this better, incorporating it into sprouts more
seamlessly, etc.


##############################
# bundle exec rake compile_locale['partnerX_en_US']
# prereq: run copylocale one time with your custom locale. (Haven't
automated this yet.)
# e.g. ~/Library/Sprouts/1.1/cache/flex4/4.1.0.16076A/bin/copylocale
en_US partnerX_en_US

desc 'Compile a locale swf by specifying its base name. resource
bundle folder should live at resource_bundles/basename. REQUIRES
RUNNING THE COPYLOCALE UTILITY ONCE FIRST.'
task :compile_locale, :locale_name do |t, args|
# The new locale swf will be placed in the following locations
dirs = [ "bin-debug", "html-template", "bin-release" ].map { |p|
"#{p}/locale" }
targets = dirs.map { |p| "#{p}/#{args[:locale_name]}.swf" }
targets.each { |file|
if File.exists?(file)
puts "remove #{file}..."
puts `rm #{file}` # do rm -i to be prompted prior to delete
end
}
target = targets.shift
puts `mkdir -p #{dirs.shift}`

mxmlc target do |t|
t.source_path << "resource_bundles/#{args[:locale_name]}"
t.locale = args[:locale_name]
t.include_resource_bundles << "ui"
t.allow_source_path_overlap = true
t.target_player = TARGET_PLAYER
end
Rake::Task[target].execute

targets.each { |file|
dir = dirs.shift
puts `mkdir -p #{dir}; cp #{target} #{file}` unless File.exists?
(file)
}

end
Reply all
Reply to author
Forward
0 new messages