SapphireSteel Forum
Welcome, Guest. Please login or register.
May 24, 2013, 04:14:48 PM

Login with username, password and session length
Search:     Advanced search
Welcome to the SapphireSteel forum - for discussion of the Ruby In Steel and Amethyst IDEs
3884 Posts in 800 Topics by 669 Members
Latest Member: m
* Home Help Search Login Register
+  SapphireSteel Forum
|-+  General
| |-+  Amethyst
| | |-+  Locale property files
« previous next »
Pages: [1] Print
Author Topic: Locale property files  (Read 1419 times)
rkosko
Jr. Member
**
Posts: 65


« on: June 05, 2012, 09:57:53 AM »

HI All,

My requirements are to build a Flex module to support localization for English and Spanish.

As per the instructions provided on the page http://www.nbilyk.com/flex-localization-example

I have created a test property file for English and Spanish

The above page suggests to use ANT to build the resource files.

I was wondering is Ameryst can do this by changeing the files Property Page Build As to Resource?

Will this suffice?

Thank you

Bob
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #1 on: June 05, 2012, 11:55:48 AM »

Look in the Project Property page, Application tab. You should see a 'Locale' listbox - just check en_US and es_ES for English and Spanish.

Then click on the Libraries tab, then Resource Bundles. Right click and the Add. Then click on the added line to edit it to the name of the bundle.

You will probably need to set a library path so that the compiler can find it - click on Paths then Library Paths and do the same.

The Paths listbox editing isn't that great and I think we might try and improve that for the next version of Amethyst.

If something goes wrong (typically a path or something) it can be a bit tricky to find out what's happened - the Adobe compiler doesn't produce the clearest error messages in the world -  so the thing to do here is to pick out the command line that's output in the Output window:

Code:
"C:\Flex SDKs\flex_sdk_4.6.0.23201B\bin\mxmlc.exe" -incremental=true -load-config+="C:\Users\dermot\AppData\Local\Temp\FlexApplication.xml" -output "C:\Data\Amethyst_2_Test\FlexApplication\FlexApplication\bin\Debug\FlexApplication.swf" -- "C:\Data\Amethyst_2_Test\FlexApplication\FlexApplication\bin\Debug\temp\src\FlexApplication.mxml"

and look at the xml configuration file "C:\Users\dermot\AppData\Local\Temp\FlexApplication.xml". This is what the compiler uses and you can edit this directly and use the command line in a command prompt box (aka DOS box) to repeatedly re-run the compilation until you get it right. Then put the settings back into Amethyst.

I've done this using Spanish and English some time ago, so I know it works. You don't need ant.

Dermot
Logged
rkosko
Jr. Member
**
Posts: 65


« Reply #2 on: June 05, 2012, 01:57:39 PM »

Thank you Dermot

What settings to I need with the property files. I am using Compile. Is that correct? Or should I use Resource?

I have tried both to no avail.

Bob
Logged
rkosko
Jr. Member
**
Posts: 65


« Reply #3 on: June 05, 2012, 02:58:52 PM »

maybe to clarify the situation

here is my bundle text for spanish

# locale/sp/myBundle.properties
ChoosePath=Elige tu camino?
NewPlayer=Jugador nuevo
ExistingPlayer=Jugador existente

for english

# locale/en_US/myBundle.properties
ChoosePath=Choose Your Path...
NewPlayer=New Player
ExistingPlayer=Existing Player

both files are called myBundle.properties

and lcated in locale/en_us and locale/sp

Bob
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #4 on: June 05, 2012, 04:16:40 PM »

I've located the project I used to test this ... the .properties files are set to Content and the project creates a resources .swc which I think is then used in another project (which uses the settings that I suggested earlier). So it looks like you build the resources SWC (also know as a resources bundle), and then link that in to the main project.

I'll do a bit more searching tomorrow and see if I can find (or reconstruct) the whole project and post it as an example.

Dermot
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #5 on: June 06, 2012, 05:49:15 AM »

I've done some more work on this and as far as I can tell, all you need to do is

1) add the resource bundle name (say 'test') to the 'Resource Bundles' tab
2) check the required locales in the Application tab
3) add 'locale\{locale} to the Source paths settings (in Paths).
4) add "-allow-source-path-overlap=true" to the Additional Compiler options
5) the test.properties files are then located  under directories like 'locale\de_DE' and have the Build Action set to 'Content'

I think the resource bundles are then compiled into the output SWF and you can get them directly from the file as in the Adobe examples.

I haven't got my full load resource bundle example working yet because I'm having some trouble loading the generated resource bundle swf (cross domain security problems). There some extra classes required to sort this out for local files, I think.

Dermot
Logged
rkosko
Jr. Member
**
Posts: 65


« Reply #6 on: June 06, 2012, 06:13:25 AM »

Thank you Dermot

I have done everything you said but the build would fail. I had to remove the additional complier option statement -allow-source-path-overlap=true for the build to succeed.

Also the Compiler Service would crash and I would have to restart it.

Even after a clean build no bundle SWF were created.

Bob
Logged
rkosko
Jr. Member
**
Posts: 65


« Reply #7 on: June 06, 2012, 07:06:43 AM »

Dermot

I turn off the complier service and I was able to use the compiler option you gave me.

But still no bundle SWF has arrived.

Bob
Logged
rkosko
Jr. Member
**
Posts: 65


« Reply #8 on: June 06, 2012, 07:23:33 AM »

Here is my diagnostic ouput, I have removed code warnings for brevity

------ Rebuild All started: Project: Login, Configuration: Debug AnyCPU ------
Build started.

Build started.
Project "Login.amproj" (ReBuild target(s)):

Project "Login.amproj" (ReBuild target(s)):
Building with tools version "3.5".
Target "Clean" in project "Login.amproj"

   Target "Clean" in project "Login.amproj"
   Using "CleanTask" task from assembly "C:\Program Files (x86)\MSBuild\SapphireSteel Software\Amethyst 2010\AmethystBuild.dll".
   Task "CleanTask"

      Task "CleanTask"
      Deleting file 'C:\Users\rkosko\Spanish Selene Source\src\sas\..\..\HTML\SWF\Login\main.swf':
      Deleting file 'C:\Users\rkosko\Spanish Selene Source\src\sas\..\..\HTML\SWF\Login\main.swf.cache':
      Deleting file 'C:\Users\rkosko\AppData\Local\Temp\main.xml':

   Done executing task "CleanTask".

Done building target "Clean" in project "Login.amproj".
Target "Initialize" in project "Login.amproj"

   Target "Initialize" in project "Login.amproj"
   Task "Message"

      Task "Message"
      Output path is "C:\Users\rkosko\Spanish Selene Source\src\sas\..\..\HTML\SWF\Login\"

   Done executing task "Message".
   Task "MakeDir"

      Task "MakeDir"

   Done executing task "MakeDir".

Done building target "Initialize" in project "Login.amproj".
Target "ProcessReferences" in project "Login.amproj"

   Target "ProcessReferences" in project "Login.amproj"

Done building target "ProcessReferences" in project "Login.amproj".
Target "BeforeBuild" skipped, due to false condition; ('$(PreBuildEvent)'!='' ) was evaluated as (''!='' ).
Target "BuildFlash" skipped, due to false condition; ('$(AmethystProjectType)'=='Flash' Or '$(AmethystProjectType)'=='FlashAIR') was evaluated as ('Flex'=='Flash' Or 'Flex'=='FlashAIR').
Target "BuildSWF" in project "Login.amproj"

   Target "BuildSWF" in project "Login.amproj"
   Building target "BuildSWF" completely.
   Output file "C:\Users\rkosko\Spanish Selene Source\src\sas\..\..\HTML\SWF\Login\main.swf" does not exist.
   Task "Message"

      Task "Message"
      Building SWF for main.mxml

   Done executing task "Message".
   Using "MXMLCompilerTask" task from assembly "C:\Program Files (x86)\MSBuild\SapphireSteel Software\Amethyst 2010\AmethystBuild.dll".
   Task "MXMLCompilerTask"

      Task "MXMLCompilerTask"
      Working directory is 'C:\Users\rkosko\Spanish Selene Source\src\sas\..\..\HTML\SWF\Login\'
      "C:\Program Files (x86)\flex_sdk_35\bin\mxmlc.exe" -incremental=true -load-config+="C:\Users\rkosko\AppData\Local\Temp\main.xml" -allow-source-path-overlap=true -output "C:\Users\rkosko\Spanish Selene Source\src\sas\..\..\HTML\SWF\Login\main.swf" -- "C:\Users\rkosko\Spanish Selene Source\src\sas\main.mxml"
      Compiler timeout set to 120 seconds
      Loading configuration file C:\Program Files (x86)\flex_sdk_35\frameworks\flex-config.xml
      Loading configuration file C:\Users\rkosko\AppData\Local\Temp\main.xml
            
      C:\Users\rkosko\Spanish Selene Source\HTML\SWF\Login\main.swf (675780 bytes)


      'C:\Users\rkosko\Spanish Selene Source\src\sas\..\..\HTML\SWF\Login\main.swf' exists in trust file
      Compile succeeded

   Done executing task "MXMLCompilerTask".

Done building target "BuildSWF" in project "Login.amproj".
Target "BuildSWC" skipped, due to false condition; ('$(AmethystProjectType)'=='Library') was evaluated as ('Flex'=='Library').
Target "BuildAir" skipped, due to false condition; ('$(AmethystProjectType)'=='AIR') was evaluated as ('Flex'=='AIR').
Target "AfterBuild" skipped, due to false condition; ('$(PostBuildEvent)'!='' ) was evaluated as (''!='' ).
Target "Build" in project "Login.amproj"

   Target "Build" in project "Login.amproj"

Done building target "Build" in project "Login.amproj".
Target "Rebuild" in project "Login.amproj"

   Target "Rebuild" in project "Login.amproj"

Done building target "Rebuild" in project "Login.amproj".
Done building project "Login.amproj".

Done building project "Login.amproj".

Build succeeded.

Build succeeded.
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #9 on: June 06, 2012, 08:54:57 AM »

I'll have a look at the compiler service - the compiler option isn't that important anyway, it just stops the compiler moaning about overlapping source paths.

Look at the file "C:\Users\rkosko\AppData\Local\Temp\main.xml". This is generated by Amethyst for use by the compiler and it should look a bit like this:

Code:
<?xml version="1.0"?>
<flex-config xmlns="http://www.adobe.com/2006/flex-config">
<compiler>
<debug>true</debug>
<locale>
<locale-element>de_DE</locale-element>
<locale-element>en_US</locale-element>
<locale-element>fr_FR</locale-element>
</locale>
<source-path>
<path-element>C:\Data\Amethyst_2_Test\ResourceBundle\locale\{locale}</path-element>
<path-element>C:\Data\Amethyst_2_Test\ResourceBundle\</path-element>
</source-path>
<namespaces>
</namespaces>
<optimize>false</optimize>
</compiler>
<include-resource-bundles>
<bundle>test</bundle>
</include-resource-bundles>
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
</flex-config>

If it does, then I think you will have the resource bundles incorporated into the main output SWF (it wont create a new one). The key bits are the include-resources-bundles and the locales. You should be able to load the resources by running a piece of code in the SWF as in this example http://livedocs.adobe.com/flex/3/html/help.html?content=l10n_1.html

Dermot
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #10 on: June 06, 2012, 03:47:45 PM »

Finally got it working!

It's a two step process to create a resource bundle SWF.

First you create an 'application' SWF by using the above approach (using an MXML file as the main file). However, you *don't* want this - it will *not* load using loadResourceModule. Next you copy the compiler command line from the output window, past it into a command prompt and remove the last bit starting with '--' (so that there isn't a main file). Run this, and you get a 'module' SWF which does load using loadResourceModule. You can put this last bit into the post build command if you want to fully automate things.

I'll post a full example with instructions and a zip file tomorrow.

I've been mislead by Adobe's useless error messages! Nothing to do with cross-domain security!!

Dermot
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #11 on: June 07, 2012, 05:10:54 AM »

I've uploaded a zip file to http://sapphiresteel.com/downloads/misc/ResourceBundle.zip

It's got a VS2010 solution with two projects in it. The first project, ResourceBundle, creates a resource bundle swf called TestResourceBundle.swf. This is created in the Post Exec build step.

The second project, TestLocalization, loads the resource bundle and uses it to alter the text of a button. It's a very simple example.

It should all work, but you will need to change the SDK locations in both projects and the text of the post build step to use the correct generated xml file.

Dermot

Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!