Upgrade babelfx to 2.0.4, add more injectors to the localmap, and rework the loading...
authorAndy Allan <andy@gravitystorm.co.uk>
Sat, 26 Nov 2011 14:46:51 +0000 (14:46 +0000)
committerAndy Allan <andy@gravitystorm.co.uk>
Sat, 26 Nov 2011 14:46:51 +0000 (14:46 +0000)
Based on awesome work by Hiroshi Miura.

l10n/map/LocalizationMap.mxml
lib/Framework_BabelFx-2.0.4.swc [new file with mode: 0644]
lib/Framework_BabelFx-g400a96.swc [deleted file]
potlatch2.mxml

index b96a414..2118865 100644 (file)
@@ -2,22 +2,31 @@
 <LocaleMap enableLog="false"
     xmlns:mx="http://www.adobe.com/2006/mxml"
     xmlns:factory="mx.core.*"
-    xmlns="library://ns.babelfx.org/l10n/flex/" >
+    xmlns="http://l10n.babelfx.org/" >
 
   <!-- Support for Locale ResourceBundle changes -->
   <mx:Script>
     <![CDATA[
-      import com.mindspace.l10n.commands.ExternalLocaleCommand;
+      import org.babelfx.commands.ExternalLocaleCommand;
+      import org.babelfx.events.LocaleEvent;
       import mx.resources.ResourceManager;
       import mx.resources.IResourceManager;
 
       import net.systemeD.potlatch2.help.HelpDialog;
+
       import net.systemeD.potlatch2.TagViewer;
       import net.systemeD.potlatch2.Toolbox;
+      import net.systemeD.potlatch2.StyleSelector;
+      import net.systemeD.potlatch2.BackgroundSelector;
+
+      import net.systemeD.potlatch2.save.OAuthPanel;
+      import net.systemeD.potlatch2.save.SaveDialog;
+
+      import net.systemeD.potlatch2.options.OptionsDialog;
 
       private function onLocaleChanged(event:Event):void {
           var rMngr : IResourceManager = ResourceManager.getInstance();
-          var sri : SmartResourceInjector = event.target as SmartResourceInjector;
+          var sri : ResourceInjector = event.target as ResourceInjector;
           var options : Array = [
                                   { label : rMngr.getString('p2_main','main.gps_data') },
                                   { label : rMngr.getString('p2_main','main.my_tracks') },
   </commandFactory>
 
   <!--
-  SmartResourceInjectors for targeted class instantiations. Instead of dependency injection of UI instances,
-  we use SRI(s) here to remove any need to know view hierarchy relationships... we simply want a reference
+  ResourceInjectors(at v2) for targeted class instantiations. Instead of dependency injection of UI instances,
+  we use RI(s) here to remove any need to know view hierarchy relationships... we simply want a reference
   to the UI instance when ready.
   -->
 
-  <SmartResourceInjector bundleName="help_dialog" target="{HelpDialog}">
-    <ResourceProxy property="gettingStarted.text" key="help.gettingStarted" />
-    <ResourceProxy property="welcome.label" key="help.welcome" />
-  </SmartResourceInjector>
-
-  <SmartResourceInjector bundleName="p2_main" target="{potlatch2}" localeChange="onLocaleChanged(event)">
-    <ResourceProxy property="bgButton.label" key="main.background" />
-    <ResourceProxy property="styleButton.label" key="main.map_style" />
-    <ResourceProxy property="undo.label" key="main.undo" />
-    <ResourceProxy property="redo.label" key="main.redo" />
-    <ResourceProxy property="helpButton.label" key="main.help" />
-    <ResourceProxy property="optionsButton.label" key="main.options" />
-    <ResourceProxy property="saveButton.label" key="main.save" />
-  </SmartResourceInjector>
-
-  <SmartResourceInjector bundleName="p2_main" target="{TagViewer}">
-    <ResourceProxy property="dndPrompt" key="tag_viewer.dndprompt" />
-  </SmartResourceInjector>
-
-  <SmartResourceInjector bundleName="p2_main" target="{Toolbox}">
-    <ResourceProxy property="deleteNode" key="toolbox.delete_node" />
-    <ResourceProxy property="deleteWay" key="toolbox.delete_way" />
-    <ResourceProxy property="deleteArea" key="toolbox.delete_area" />
-    <ResourceProxy property="deleteItem" key="toolbox.delete_item" />
-    <ResourceProxy property="reverseButton.toolTip" key="toolbox.reverse_direction" />
-    <ResourceProxy property="splitButton.toolTip" key="toolbox.split_way" />
-    <ResourceProxy property="mergeButton.toolTip" key="toolbox.merge_ways" />
-    <ResourceProxy property="straightenButton.toolTip" key="toolbox.straighten_way" />
-    <ResourceProxy property="circulariseButton.toolTip" key="toolbox.make_circular" />
-    <ResourceProxy property="quadrilateraliseButton.toolTip" key="toolbox.make_right_angled" />
-    <ResourceProxy property="parralleliseButton.toolTip" key="toolbox.create_parrallel_way" />
-  </SmartResourceInjector>
-
-</LocaleMap>
\ No newline at end of file
+  <ResourceInjector bundleName="help_dialog" target="{HelpDialog}">
+    <ResourceSetter property="gettingStarted.text" key="help.gettingStarted" />
+    <ResourceSetter property="welcome.label" key="help.welcome" />
+    <ResourceSetter property="whyOpenStreetMap.htmlText" key="help.whyOpenstreetmap" />
+    <ResourceSetter property="activeMembers.htmlText" key="help.activeMembers" />
+    <ResourceSetter property="newMembersText.htmlText" key="help.newMembers" />
+    <!-- wanna call loaderInfo.parameters["site_name"] or getIntroText() -->
+    <!-- <ResourceSetter property="introText.htmlText" key="help.introText" parameters="that"/> -->
+    <ResourceSetter property="Introduction.label" key="help.introduction" />
+    <ResourceSetter property="Controls.label" key="help.controls" />
+    <ResourceSetter property="interfaceControls.label" key="help.interfaceControls"/>
+    <ResourceSetter property="background.label" key="help.background"/>
+    <ResourceSetter property="mapBackground.htmlText" key="help.mapBackground"/>
+    <ResourceSetter property="mapStyle.label" key="help.mapStyle"/>
+    <ResourceSetter property="colourStyle.htmlText" key="help.colourStyle"/>
+    <ResourceSetter property="gps.label" key="help.gps"/>
+    <ResourceSetter property="createOsmMap.htmlText" key="help.createOsmMap"/>
+    <ResourceSetter property="undoRedo.label" key="help.undoRedo" />
+    <ResourceSetter property="madeMistake.htmlText" key="help.madeMistake" />
+    <ResourceSetter property="help.label" key="help.help" />
+    <ResourceSetter property="guideInfomation.htmlText" key="help.guideInfomation" />
+    <ResourceSetter property="save.label" key="help.save" />
+ <!--   <ResourceSetter property="saveText.htmlText" key="help.saveText" />    -->
+    <ResourceSetter property="addingFeatures.label" key="help.addingFeatures" />
+    <ResourceSetter property="addingFeaturesText.htmlText" key="help.addingFeaturesText" />
+    <ResourceSetter property="editBeg.label" key="help.editBeg" />
+    <ResourceSetter property="editingFeatures.label" key="help.editingFeatures" />
+    <ResourceSetter property="editingFeaturesText.htmlText" key="help.editingFeaturesText" />
+    <ResourceSetter property="editAdv.label" key="help.editAdv" />
+    <ResourceSetter property="editingFeaturesAdv.label" key="help.editingFeaturesAdv"/>
+    <ResourceSetter property="editingFeaturesAdvText.htmlText" key="help.editingFeaturesAdvText"/>
+    <ResourceSetter property="tag.label" key="help.tag" />
+    <ResourceSetter property="taggingFeatures.label" key="help.taggingFeatures" />
+    <ResourceSetter property="taggingFeaturesText.htmlText" key="help.taggingFeaturesText" />
+    <ResourceSetter property="shortcuts.label" key="help.shortcuts" />
+    <ResourceSetter property="keyboardShortcuts.label" key="help.keyboardShortcuts" />
+  </ResourceInjector>
+
+  <ResourceInjector bundleName="p2_main" target="{potlatch2}" localeChange="onLocaleChanged(event);">
+    <ResourceSetter property="bgButton.label" key="main.background" />
+    <ResourceSetter property="styleButton.label" key="main.map_style" />
+    <ResourceSetter property="undo.label" key="main.undo" />
+    <ResourceSetter property="redo.label" key="main.redo" />
+    <ResourceSetter property="helpButton.label" key="main.help" />
+    <ResourceSetter property="optionsButton.label" key="main.options" />
+    <ResourceSetter property="saveButton.label" key="main.save" />
+    <ResourceSetter property="gpsButton.label" key="main.gpsButton" />
+  <!--   These are setted on onLocaleChanged()
+    <ResourceSetter property="gpsData.label" key="main.gps_data" />
+    <ResourceSetter property="myTrack.label" key="main.my_track" />
+    <ResourceSetter property="clearGps.label" key="main.clear_gps" />
+    -->
+  </ResourceInjector>
+
+  <ResourceInjector bundleName="p2_main" target="{OAuthPanel}">
+    <ResourceSetter property="gotLinkBox.text" key="oauth.gotLinkBox" />
+    <ResourceSetter property="authorized.text" key="oauth.authorized" />
+    <ResourceSetter property="deniedLabel.text" key="oauth.deniedLabel" />
+    <ResourceSetter property="rememberMe.label" key="oauth.rememberMe" />
+    <ResourceSetter property="permFail.htmlText" key="oauth.permFail" />
+    <ResourceSetter property="tempFail.text" key="oauth.tempFail" />
+    <ResourceSetter property="tryAccessButton.label" key="oauth.tryAccessButton" />
+    <ResourceSetter property="cancelButton.label" key="oauth.cancelButton" />
+  </ResourceInjector>
+
+  <ResourceInjector bundleName="p2_main" target="{TagViewer}">
+    <ResourceSetter property="dndPrompt" key="tag_viewer.dndprompt" />
+  </ResourceInjector>
+
+  <ResourceInjector bundleName="p2_main" target="{Toolbox}">
+    <ResourceSetter property="deleteNode" key="toolbox.delete_node" />
+    <ResourceSetter property="deleteWay" key="toolbox.delete_way" />
+    <ResourceSetter property="deleteArea" key="toolbox.delete_area" />
+    <ResourceSetter property="deleteItem" key="toolbox.delete_item" />
+    <ResourceSetter property="reverseButton.toolTip" key="toolbox.reverse_direction" />
+    <ResourceSetter property="splitButton.toolTip" key="toolbox.split_way" />
+    <ResourceSetter property="mergeButton.toolTip" key="toolbox.merge_ways" />
+    <ResourceSetter property="straightenButton.toolTip" key="toolbox.straighten_way" />
+    <ResourceSetter property="circulariseButton.toolTip" key="toolbox.make_circular" />
+    <ResourceSetter property="quadrilateraliseButton.toolTip" key="toolbox.make_right_angled" />
+    <ResourceSetter property="parralleliseButton.toolTip" key="toolbox.create_parrallel_way" />
+  </ResourceInjector>
+
+  <ResourceInjector bundleName="p2_main" target="{StyleSelector}">
+    <ResourceSetter property="editButton.label" key="styleSelector.editButton" />
+  </ResourceInjector>
+
+  <ResourceInjector bundleName="p2_main" target="{BackgroundSelector}">
+    <ResourceSetter property="dim.label" key="backgroundSelector.dim" />
+    <ResourceSetter property="sharpen.label" key="backgroundSelector.sharpen" />
+    <ResourceSetter property="editButton.label" key="backgroundSelector.editButton" />
+    <ResourceSetter property="vectorButton.label" key="backgroundSelector.vectorButton" />
+  </ResourceInjector>
+
+  <ResourceInjector bundleName="p2_main" target="{SaveDialog}">
+    <ResourceSetter property="editDescription.text" key="save.editDescription" />
+    <ResourceSetter property="commentLabel.label" key="save.commentLabel" />
+  </ResourceInjector>
+
+  <ResourceInjector bundleName="p2_main" target="{OptionsDialog}">
+    <ResourceSetter property="tbcheck.label" key="options.tbcheck" />
+    <ResourceSetter property="cursorcheck.label" key="options.cursorcheck" />
+    <ResourceSetter property="ok.label" key="option.ok" />
+  </ResourceInjector>
+</LocaleMap>
diff --git a/lib/Framework_BabelFx-2.0.4.swc b/lib/Framework_BabelFx-2.0.4.swc
new file mode 100644 (file)
index 0000000..e4ec660
Binary files /dev/null and b/lib/Framework_BabelFx-2.0.4.swc differ
diff --git a/lib/Framework_BabelFx-g400a96.swc b/lib/Framework_BabelFx-g400a96.swc
deleted file mode 100644 (file)
index ccba27d..0000000
Binary files a/lib/Framework_BabelFx-g400a96.swc and /dev/null differ
index 7c16e28..fc3c224 100644 (file)
@@ -48,7 +48,7 @@
             creationComplete="bgButton.popUp = new BackgroundSelector();"/>
         <mx:PopUpButton id="styleButton" label="Map Style" openAlways="true" styleName="appBarButton"
             creationComplete="styleButton.popUp = new StyleSelector();"/>
-               <mx:PopUpMenuButton id="gpsButton" styleName="appBarButton"
+               <mx:PopUpMenuButton id="gpsButton" label="GPS Data" styleName="appBarButton"
                    itemClick="if (event.index==0) { trackLoader.load(); } 
                          else if (event.index==1) { new MyGpxDialog().init(); } 
                                              else { mx.controls.Menu(gpsButton.popUp).selectedIndex=0; 
         import mx.managers.DragManager;
         import mx.core.DragSource;
         import mx.controls.Alert;
-        import com.mindspace.l10n.events.LocaleEvent;
+        import org.babelfx.events.LocaleEvent;
 
         public var theMap:Map;
         public var theController:EditController;
         include "version.as";
 
                private function startInit():void {
-            /* For reasons that I don't yet understand, the en_US locale is the default and doesn't work at all. */
-            /* Change this to another locale (e.g. fr_FR) to see the differences. */
-            if (loaderInfo.parameters['locale']) {
-              dispatchEvent(new LocaleEvent(LocaleEvent.LOAD_LOCALE,loaderInfo.parameters['locale']));
-            }
                        var loader:Loader = new Loader();
                        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, startApp);
                        loader.load(new URLRequest("FontLibrary.swf"));
+
+            if (loaderInfo.parameters['locale']) {
+                Globals.vars.locale = loaderInfo.parameters['locale'];
+                dispatchEvent(new LocaleEvent(LocaleEvent.LOAD_LOCALE, loaderInfo.parameters['locale']));
+                dispatchEvent(new LocaleEvent(LocaleEvent.LOAD_LOCALE, 'en_US')); // think en_US is default
+                resourceManager.localeChain = [loaderInfo.parameters['locale'], 'en_US'];
+            }
                }
                
                private function startApp(event:Event):void {