You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/02/26 14:38:21 UTC
[royale-asjs] 03/05: integration of validator locale with maven and
asconfigc
This is an automated email from the ASF dual-hosted git repository.
carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 4e0940cf1d5aa8b8aa174b264780a2d93ca48cc5
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Tue Feb 26 13:52:09 2019 +0100
integration of validator locale with maven and asconfigc
---
frameworks/projects/Jewel/asconfig.json | 6 ++
frameworks/projects/Jewel/pom.xml | 6 ++
.../royale/jewel/beads/validators/Validator.as | 71 ++++++++++++++++------
3 files changed, 64 insertions(+), 19 deletions(-)
diff --git a/frameworks/projects/Jewel/asconfig.json b/frameworks/projects/Jewel/asconfig.json
index cb77061..9262709 100644
--- a/frameworks/projects/Jewel/asconfig.json
+++ b/frameworks/projects/Jewel/asconfig.json
@@ -29,6 +29,12 @@
"source-path": [
"src/main/royale"
],
+ "define": [
+ {
+ "name": "LOCALE::language",
+ "value": "'en_US'"
+ }
+ ],
"output": "target/Jewel.swc"
}
}
diff --git a/frameworks/projects/Jewel/pom.xml b/frameworks/projects/Jewel/pom.xml
index 74d84db..74aa185 100644
--- a/frameworks/projects/Jewel/pom.xml
+++ b/frameworks/projects/Jewel/pom.xml
@@ -66,6 +66,12 @@
<skipExtern>true</skipExtern>
<additionalCompilerOptions>-source-map=true</additionalCompilerOptions>
<!--<additionalCompilerOptions>-compiler.fxg-base-class=flash.display.Sprite</additionalCompilerOptions>-->
+ <defines>
+ <property>
+ <name>LOCALE::language</name>
+ <value>'"en_US"'</value>
+ </property>
+ </defines>
</configuration>
</plugin>
<plugin>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
index 5b18fc1..cb829b6 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
@@ -22,16 +22,12 @@ package org.apache.royale.jewel.beads.validators
import org.apache.royale.core.ILocalizedValuesImpl;
import org.apache.royale.core.IPopUpHost;
import org.apache.royale.core.IStrand;
- import org.apache.royale.core.SimpleLocalizedValuesImpl;
import org.apache.royale.core.Strand;
import org.apache.royale.core.UIBase;
import org.apache.royale.events.Event;
import org.apache.royale.events.IEventDispatcher;
import org.apache.royale.geom.Point;
import org.apache.royale.jewel.supportClasses.tooltip.ErrorTipLabel;
- import org.apache.royale.utils.PointUtils;
- import org.apache.royale.utils.UIUtils;
- import org.apache.royale.utils.loadBeadFromValuesManager;
/**
* The Validator class is the base class for all validators.
@@ -45,11 +41,25 @@ package org.apache.royale.jewel.beads.validators
*/
public class Validator extends Strand implements IBead
{
+ /**
+ * locale
+ */
+ public static var locale :String = LOCALE::language;
+
[Embed("locale/en_US/validator.properties", mimeType="text/plain")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public var en_USvalidator:String;
[Embed("locale/de_DE/validator.properties", mimeType="text/plain")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public var de_DEvalidator:String;
[Embed("locale/es_ES/validator.properties", mimeType="text/plain")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public var es_ESvalidator:String;
/**
@@ -146,26 +156,46 @@ package org.apache.royale.jewel.beads.validators
public function set strand(value:IStrand):void
{
hostComponent = value as UIBase;
-
- //get translations from bundles
- try{
- var resourceManager:SimpleLocalizedValuesImpl = loadBeadFromValuesManager(ILocalizedValuesImpl, "iLocalizedValuesImpl", this) as SimpleLocalizedValuesImpl;
- resourceManager.localeChain = "es_ES";
- var rfe:String = resourceManager.getValue("validator", "requiredFieldError");
- _requiredFieldError = rfe
- }
- catch(e:Error)
- {
- trace(e.message);
- }
-
_trigger = hostComponent;
-
COMPILE::JS
{
hostClassList = hostComponent.positioner.classList;
}
}
+
+ /**
+ * @private
+ */
+ private var _resourceManager:ILocalizedValuesImpl;
+ /**
+ * The Validator's resource manager to get translations from bundles
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ * @royaleignorecoercion org.apache.royale.core.ILocalizedValuesImpl
+ */
+ public function get resourceManager():ILocalizedValuesImpl
+ {
+ if (_resourceManager == null) {
+ var c:Class = ValuesManager.valuesImpl.getValue(this, "iLocalizedValuesImpl");
+ if (c) {
+ _resourceManager = new c() as ILocalizedValuesImpl;
+ _resourceManager.localeChain = locale;
+ addBead(_resourceManager);
+ }
+ }
+ return _resourceManager;
+ }
+ /**
+ * @royaleignorecoercion org.apache.royale.core.ILocalizedValuesImpl
+ */
+ public function set resourceManager(value:ILocalizedValuesImpl):void
+ {
+ _resourceManager = value;
+ }
+
/**
* Contains true if the field generated a validation failure.
*
@@ -225,7 +255,7 @@ package org.apache.royale.jewel.beads.validators
_required = value;
}
- private var _requiredFieldError:String = "NO TRANS";
+ private var _requiredFieldError:String;
/**
* The string to use as the errorTip.
*
@@ -236,6 +266,9 @@ package org.apache.royale.jewel.beads.validators
*/
public function get requiredFieldError():String
{
+ if(_requiredFieldError == null) {
+ _requiredFieldError = resourceManager.getValue("validator", "requiredFieldError");
+ }
return _requiredFieldError;
}
public function set requiredFieldError(value:String):void