This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 4583e1e  Adding a simple ResourceManger example. Was primarily used 
for testing, but can be used as a simple example. Needs more work (locale 
switching not currently working on swf side in Royale - but same code works in 
Flex).
4583e1e is described below

commit 4583e1e360e3502bf8e9ac45af5dd0d7c4323078
Author: greg-dove <[email protected]>
AuthorDate: Thu Nov 18 21:39:32 2021 +1300

    Adding a simple ResourceManger example. Was primarily used for testing, but 
can be used as a simple example.
    Needs more work (locale switching not currently working on swf side in 
Royale - but same code works in Flex).
---
 examples/build.xml                                 |  1 +
 examples/mxroyale/ResourceManagerExample/build.xml | 56 +++++++++++++++++++
 .../locale/en_US/Something.properties              | 27 +++++++++
 .../locale/fr_FR/Something.properties              | 27 +++++++++
 examples/mxroyale/ResourceManagerExample/pom.xml   | 65 ++++++++++++++++++++++
 .../src/main/royale/ResourceManagerExample.mxml    | 62 +++++++++++++++++++++
 examples/mxroyale/pom.xml                          |  1 +
 7 files changed, 239 insertions(+)

diff --git a/examples/build.xml b/examples/build.xml
index fdc170f..10e307e 100644
--- a/examples/build.xml
+++ b/examples/build.xml
@@ -124,6 +124,7 @@
         <ant dir="${basedir}/mxroyale/HelloWorld"/>
         <ant dir="${basedir}/mxroyale/ControlsExample"/>
         <ant dir="${basedir}/mxroyale/DataGridExample"/>
+        <ant dir="${basedir}/mxroyale/ResourceManagerExample"/>
         <ant dir="${basedir}/native/ButtonExample"/>
         <ant dir="${basedir}/native/USStatesMap"/>
     </target>
diff --git a/examples/mxroyale/ResourceManagerExample/build.xml 
b/examples/mxroyale/ResourceManagerExample/build.xml
new file mode 100644
index 0000000..502856e
--- /dev/null
+++ b/examples/mxroyale/ResourceManagerExample/build.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+
+
+<project name="ResourceManagerExample" default="main" basedir=".">
+    <property name="ROYALE_HOME" location="../../.."/>
+    <property name="example" value="ResourceManagerExample" />
+    
+    <property file="${ROYALE_HOME}/env.properties"/>
+    <property environment="env"/>
+    <property file="${ROYALE_HOME}/build.properties"/>
+    <property name="ROYALE_HOME" value="${ROYALE_HOME}"/>
+    <property name="config_arg" value="flex"/>
+    <!-- adding in some commandline args for locale stuff -->
+    <property name="optional_arg" value="-locale=en_US,fr_FR 
-compiler.source-path+=${basedir}\locale\{locale}"/>
+    <include file="${basedir}/../../build_example.xml" />
+    
+    <target name="main" depends="clean,build_example.compile" 
description="Clean build of ${example}">
+    </target>
+    
+    <target name="clean">
+        <delete dir="${basedir}/bin" failonerror="false" />
+        <delete dir="${basedir}/bin-debug" failonerror="false" />
+        <delete dir="${basedir}/bin-release" failonerror="false" />
+        <delete dir="${basedir}/target" failonerror="false" />
+    </target>
+
+    <target name="examine" depends="build_example.get.browser">
+        <property name="which" value="debug" />
+        <echo message="Make sure label appears."/>
+        <exec executable="${browser}" dir="${basedir}/bin-${which}" 
failonerror="true">
+            <arg value="${basedir}/bin-${which}/${example}.html"/>
+        </exec>
+        <exec executable="${browser}" dir="${basedir}/bin/js-${which}" 
failonerror="true">
+            <arg value="${basedir}/bin/js-${which}/index.html"/>
+        </exec>
+    </target>
+
+</project>
diff --git 
a/examples/mxroyale/ResourceManagerExample/locale/en_US/Something.properties 
b/examples/mxroyale/ResourceManagerExample/locale/en_US/Something.properties
new file mode 100644
index 0000000..1304353
--- /dev/null
+++ b/examples/mxroyale/ResourceManagerExample/locale/en_US/Something.properties
@@ -0,0 +1,27 @@
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+TEST1=(EN) Something normal
+TEST2=(EN) Something with "double quotes"
+TEST3=(EN) Something with "double quotes" and a \" single backslash quote
+TEST4=(EN) Something with "double quotes" and a \" single backslash quote and 
a \\\" double backslash/backslash quote
+TEST5=(EN) Something with multiple \
+  lines in the source.
+TEST6=(EN) Something that ends with double backslash\\
+#double backslash doesn't work at EOL
+TEST7=(EN) Somethng with two {0} replacement {1} tokens
\ No newline at end of file
diff --git 
a/examples/mxroyale/ResourceManagerExample/locale/fr_FR/Something.properties 
b/examples/mxroyale/ResourceManagerExample/locale/fr_FR/Something.properties
new file mode 100644
index 0000000..6b5a37c
--- /dev/null
+++ b/examples/mxroyale/ResourceManagerExample/locale/fr_FR/Something.properties
@@ -0,0 +1,27 @@
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+TEST1=(FR) Quelque chose de normal
+TEST2=(FR) Quelque chose avec des "guillemets doubles"
+TEST3=(FR) Quelque chose avec des "guillemets doubles" et une \" guillemet 
barre oblique inverse
+TEST4=(FR) Quelque chose avec des "guillemets doubles" et une \" guillemet 
barre oblique inverse et un \\\" guillemet double barre oblique inverse
+TEST5=(FR) Quelque chose avec plusieurs lignes \
+  dans la source.
+TEST6=(FR) Quelque chose qui se termine par une double barre oblique inverse\\
+#la double barre oblique inverse ne fonctionne pas en fin de ligne
+TEST7=(FR) Quelque chose avec deux {0} jetons de remplacement {1}
\ No newline at end of file
diff --git a/examples/mxroyale/ResourceManagerExample/pom.xml 
b/examples/mxroyale/ResourceManagerExample/pom.xml
new file mode 100644
index 0000000..68cd2a0
--- /dev/null
+++ b/examples/mxroyale/ResourceManagerExample/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+--><project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.royale.examples</groupId>
+    <artifactId>examples-mxroyale</artifactId>
+    <version>0.9.9-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>ResourceManagerExample-MXRoyale</artifactId>
+  <version>0.9.9-SNAPSHOT</version>
+  <packaging>swf</packaging>
+
+  <name>Apache Royale: Examples: MXRoyale: ResourceManagerExample</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.royale.compiler</groupId>
+        <artifactId>royale-maven-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <mainClass>ResourceManagerExample.mxml</mainClass>
+          <allowSubclassOverrides>true</allowSubclassOverrides>
+          <targets>${royale.targets}</targets>
+          <debug>false</debug>
+          <additionalCompilerOptions>
+            -locale=en_US,fr_FR;
+            -compiler.source-path+=${project.basedir}\locale\{locale};
+          </additionalCompilerOptions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.royale.framework</groupId>
+      <artifactId>BasicTheme</artifactId>
+      <version>0.9.9-SNAPSHOT</version>
+      <type>swc</type>
+      <scope>theme</scope>
+      <classifier>js</classifier>
+    </dependency>
+  </dependencies>
+
+<properties /></project>
diff --git 
a/examples/mxroyale/ResourceManagerExample/src/main/royale/ResourceManagerExample.mxml
 
b/examples/mxroyale/ResourceManagerExample/src/main/royale/ResourceManagerExample.mxml
new file mode 100644
index 0000000..9dea6e8
--- /dev/null
+++ 
b/examples/mxroyale/ResourceManagerExample/src/main/royale/ResourceManagerExample.mxml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
+                xmlns:mx="library://ns.apache.org/royale/mx"
+                width="600" height="400"
+                layout="horizontal">
+
+               <fx:Metadata>
+                       [ResourceBundle("Something")]
+               </fx:Metadata>
+
+
+               <fx:Script>
+                       <![CDATA[
+
+                               [Bindable]
+                               public var activeLocale:String = '';
+
+
+                               private function swapLocale():void{
+                                       var locales:Array = 
resourceManager.getLocales();
+                                       var old:String = 
resourceManager.localeChain[0];
+                                       if (locales.indexOf(old) != -1) {
+                                               
locales.splice(locales.indexOf(old), 1);
+                                       }
+                                       var idx:uint = Math.random()* 
locales.length;
+                                       activeLocale= locales[idx];
+                                       resourceManager.localeChain = 
[activeLocale];
+                               }
+                       ]]>
+               </fx:Script>
+       
+
+               <mx:Button label="{'Swap Locale '+activeLocale}" 
click="swapLocale()"/>
+               <mx:VBox>
+                       <mx:Label 
text="{resourceManager.getString('Something','TEST1')}" />
+                       <mx:Label 
text="{resourceManager.getString('Something','TEST2')}" />
+                       <mx:Label 
text="{resourceManager.getString('Something','TEST3')}" />
+                       <mx:Label 
text="{resourceManager.getString('Something','TEST4')}" />
+                       <mx:Label 
text="{resourceManager.getString('Something','TEST5')}" />
+                       <mx:Label 
text="{resourceManager.getString('Something','TEST6')}" />
+                       <mx:Label 
text="{resourceManager.getString('Something','TEST7',['{something}','{another}'])}"
 />
+               </mx:VBox>
+
+</mx:Application>
\ No newline at end of file
diff --git a/examples/mxroyale/pom.xml b/examples/mxroyale/pom.xml
index c9bc741..a915946 100644
--- a/examples/mxroyale/pom.xml
+++ b/examples/mxroyale/pom.xml
@@ -39,6 +39,7 @@
     <module>SparkHelloWorld</module>
     <module>RemoteObjectAMFTest</module>
     <module>DataGridExample</module>
+    <module>ResourceManagerExample</module>
   </modules>
 
   <build>

Reply via email to