| Package | mx.resources |
| Class | public class ResourceBundle |
| Inheritance | ResourceBundle Object |
If you want to localize in a particular language, for example French, you would
make a copy of frameworks/locale/en_US/ directory and
call it fr_FR/ and make the necessary changes to the
framework properties files.
You can compile your application kept in MyApp using
"..\bin\mxmlc.exe" -locale en_US -library-path=..\frameworks\libs
-source-path="..\frameworks\locale\{locale},
..\myLocale\{locale}" main.mxml
Note that the source-path mentions the source for both frmaework properties files as well as myApp's properties files. In this case, you would place MyAlert.properties in the myLocale/en_US and myLocale/fr_FR directories. The locale directory should be part of the compc ActionScript classpath but should not be a part of the ActionScript classpath that is used for mxmlc when building the main SWF file; for example, placing myLocale in the myApp directory would throw a compiler warning. The locale is settable through the xml config file, mxml compiler argument or through Flex builder. However, locale is not settable through the Locale class at runtime.
The framework currently supports en_US and ja_JP only. However, you can create properties files for any language and keep them under a locale folder, such as fr_FR for French.
While getting localizable text, you must specify the filename in the ResourceBundle metadata; for example:
[ResourceBundle('MyAlert')]
private static var rb:ResourceBundle;
and then access it in ActionScript using rb.getString('foo');
or in MXML using @Resource(bundle='MyAlert', key='foo').
See also
| Method | Defined By | ||
|---|---|---|---|
|
Constructor.
| ResourceBundle | ||
|
Gets a Boolean from a ResourceBundle.
| ResourceBundle | ||
|
Gets a Number from a ResourceBundle.
| ResourceBundle | ||
|
Gets an object from a ResourceBundle.
| ResourceBundle | ||
|
[static]
Gets a ResourceBundle when provided with a className.
| ResourceBundle | ||
|
Gets a string from a ResourceBundle.
| ResourceBundle | ||
|
Gets an array from a ResourceBundle.
| ResourceBundle | ||
![]() |
Indicates whether an object has a specified property defined.
| Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
| Method | Defined By | ||
|---|---|---|---|
|
You can override this method to provide
your own keys and values for a ResourceBundle or
to add objects to your custom ResourceBundle.
| ResourceBundle | ||
| ResourceBundle | () | Constructor |
public function ResourceBundle()
Constructor.
| getBoolean | () | method |
public function getBoolean(key:String, defaultValue:Boolean = true):Boolean
Gets a Boolean from a ResourceBundle.
Parameters
key:String |
|
defaultValue:Boolean (default = true) |
Boolean |
[ResourceBundle("foo")]
private static var packageResources:ResourceBundle;
packageResources.getString("myBooleanKey");
| getContent | () | method |
protected function getContent():Object
You can override this method to provide your own keys and values for a ResourceBundle or to add objects to your custom ResourceBundle. The following example adds a jpg image to a custom ResourceBundle. First you create a class called myPic. You then make a custom ResourceBundle called myBundle.
ReturnsObject |
See also
package {
[Embed(source='picture.jpg')]
public class myPic extends mx.core.SpriteAsset {}
}
package {
import mx.resources.ResourceBundle;
public class myBundle extends ResourceBundle {
public function myBundle() { super(); }
override protected static function getContent():Object {
var contentObj:Object = new Object();
content.push("myPic", myPic);
return contentObj; }}}
| getNumber | () | method |
public function getNumber(key:String):Number
Gets a Number from a ResourceBundle.
Parameters
key:String |
Number |
[ResourceBundle("foo")]
private static var packageResources:ResourceBundle;
packageResources.getString("myNumericKey");
| getObject | () | method |
public function getObject(key:String):Object
Gets an object from a ResourceBundle.
The folowing example shows how to get a
jpg image with the getObject() method.
Parameters
key:String |
Object |
See also
[ResourceBundle("MyBundle")]
private static var rb:ResourceBundle;
var sprite:SpriteAsset = SpriteAsset(rb.getObject("myPic"));
| getResourceBundle | () | method |
public static function getResourceBundle(baseName:String, currentDomain:ApplicationDomain = null):ResourceBundle
Gets a ResourceBundle when provided with a className.
Parameters
baseName:String |
|
currentDomain:ApplicationDomain (default = null) |
ResourceBundle |
private static var rb:ResourceBundle;
rb = getResourceBundle("fooBundle");
| getString | () | method |
public function getString(key:String):String
Gets a string from a ResourceBundle.
Parameters
key:String |
String |
[ResourceBundle("controls")]
private static var packageResources:ResourceBundle;
packageResources.getString("okLabel");
| getStringArray | () | method |
public function getStringArray(key:String):Array
Gets an array from a ResourceBundle.
Parameters
key:String |
Array |
[ResourceBundle("SharedResources")]
private static var sharedResources:ResourceBundle;
sharedResources.getStringArray("monthNames");
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/common/langref/mx/resources/ResourceBundle.html