IMO, Royale components would not output strings. A Validator, for example, should be focused on processing data going in or out of the model and reporting a result, probably as a Boolean, or a range of values. Elsewhere, the application code can decide what to do with that result. The Validator should not presume that a string needs to be displayed.
That way, the application developer has more choices. They can choose a different localization implementation. They can prune out localized strings they know their application will never report. I still find it amazing how much my colleagues on the Adobe Flex team and I twisted your minds on how to write code. Flex was all about large centralized subsystems, but these are actually a bad practice in modern software practices, IMO. They were necessary because Flex was originally written in AS2 on a runtime that was really bad at memory allocation. When we ported to AS3, we never found time to rewrite once we understood the behavior of the new AVM. Separation of concerns is a good thing and helps with PAYG. HTH, -Alex On 2/26/19, 8:14 AM, "Carlos Rovira" <[email protected]> wrote: Hi, I continue trying to setup Jewel for use with different locales. I still need to complete and separate locales in its own SWC, but for now my mine concern is about how to define localeChain in an App and make all classes using bundles know about this. For now I get it working, but want to ask here about the solution I put in place: 1.- in my main App.mxml file I can put this in initialize Application event: import org.apache.royale.jewel.beads.validators.Validator; public function setUp():void { // you can change language here Validator.locale = "es_ES"; } So as we have more and more classes using bundles, will be added here. This could be ok, but maybe not the final way to get over this right? 2.- Validator implementation of bundles: in CSS add the bead: j|Validator ILocalizedValuesImpl: ClassReference( "org.apache.royale.core.SimpleLocalizedValuesImpl") defining a resource manager so we can retrieve from CSS or override it for other implementation: /** * @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; } using is for requiredFieldError: private var _requiredFieldError:String; /** * The string to use as the errorTip. * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion Royale 0.9.4 */ public function get requiredFieldError():String { if(_requiredFieldError == null) { _requiredFieldError = resourceManager.getValue("validator", "requiredFieldError"); } return _requiredFieldError; } public function set requiredFieldError(value:String):void { _requiredFieldError = value; } I'm happy with this but not with this line: _resourceManager.localeChain = locale; as we get the resourceManager from CSS. Maybe this could be done directly in org.apache.royale.core.SimpleLocalizedValuesImpl ? IOW,...should we have another way to say our App to directly configure with "en_US", or "es_ES", or any other one? so we affect all at once? something like an Aspect that affect all at once. I already have this with the public static var in Validator, and could put the same in any component that needs to use a bundle, then at App startup asign this var to all static vars, but maybe you guys, have a better way to do this. Thanks -- Carlos Rovira https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C8856f6a0e97b459f5be108d69c057818%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636867944674418329&sdata=cfw0KPKh3gH6%2FW6n9b%2B5wlyxssADUqXH2cq7JGgqYjw%3D&reserved=0
