blob: 471bd30727130e518b349faf5e06c4b5adfff8cf [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!-- saved from url=(0014)about:internet --><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link rel="stylesheet" href="../../style.css" type="text/css" media="screen"><link rel="stylesheet" href="../../print.css" type="text/css" media="print"><link rel="stylesheet" href="../../override.css" type="text/css"><meta name="keywords" content="IResourceBundle,mx.resources.IResourceBundle,bundleName,bundleName,content,content,country,language,locale,locale,localeChain,variant"><title>mx.resources.IResourceBundle</title></head><body><script language="javascript" type="text/javascript" src="../../asdoc.js"></script><script language="javascript" type="text/javascript" src="../../help.js"></script><script language="javascript" type="text/javascript" src="../../cookies.js"></script><script language="javascript" type="text/javascript"><!--
asdocTitle = 'IResourceBundle - ApacheFlex API Reference';
var baseRef = '../../';
window.onload = configPage;
--></script>
<script type="text/javascript">
scrollToNameAnchor();
</script><table class="titleTable" cellpadding="0" cellspacing="0" id="titleTable" style="display:none"><tr><td class="titleTableTitle" align="left">Apache Flex 4.16.1 API Reference </td><td class="titleTableTopNav" align="right"><a href="../../package-summary.html" onclick="loadClassListFrame('../../all-classes.html')">All Packages</a>&nbsp;|&nbsp;<a href="../../class-summary.html" onclick="loadClassListFrame('../../all-classes.html')">All Classes</a>&nbsp;|&nbsp;<a href="../../all-index-A.html" onclick="loadClassListFrame('../../index-list.html')">Index</a>&nbsp;|&nbsp;<a id="framesLink1" href="../../index.html?mx/resources/IResourceBundle.html&amp;mx/resources/class-list.html">Frames</a><a id="noFramesLink1" style="display:none" href="" onclick="parent.location=document.location"> No Frames </a></td><td class="titleTableLogo" align="right" rowspan="3"><img src="../../images/logo.jpg" class="logoImage" alt="AdobeLogo" title="AdobeLogo"></td></tr><tr class="titleTableRow2"><td class="titleTableSubTitle" id="subTitle" align="left">IResourceBundle</td><td class="titleTableSubNav" id="subNav" align="right"><a href="#propertySummary">Properties</a></td></tr><tr class="titleTableRow3"><td colspan="3">&nbsp;</td></tr></table><script language="javascript" type="text/javascript" xml:space="preserve">
<!--
if (!isEclipse() || window.name != ECLIPSE_FRAME_NAME) {titleBar_setSubTitle("IResourceBundle"); titleBar_setSubNav(false,true,false,false,false,false,false,false,false,false,false ,false,false,false,false,false);}
-->
</script><div xmlns:fn="http://www.w3.org/2005/xpath-functions" class="MainContent"><table class="classHeaderTable" cellpadding="0" cellspacing="0"><tr><td class="classHeaderTableLabel">Package</td><td><a href="package-detail.html" onclick="javascript:loadClassListFrame('class-list.html')">mx.resources</a></td></tr><tr><td class="classHeaderTableLabel">Interface</td><td class="classSignature">public interface IResourceBundle</td></tr><tr><td class="classHeaderTableLabel">Implementors</td><td> <a href="../../mx/resources/ResourceBundle.html">ResourceBundle</a></td></tr></table><p></p><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Language Version :&nbsp;</b></td><td>ActionScript 3.0</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Product Version :&nbsp;</b></td><td>Flex 3</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Runtime Versions :&nbsp;</b></td><td>Flash Player 9, AIR 1.1</td></tr></table><p></p><p></p><p></p><p></p>
The IResourceBundle and IResourceManager interfaces work together
to provide localization support for Flex applications.
<p>There are three main concepts involved in localization:
locales, resources, and resource bundles.</p>
<p>A locale specifies a language and a country
for which your application has been localized.
For example, the locale <code>"en_US"</code>
specifies English as spoken in the United States.
(See the mx.resources.Locale class for more information.)</p>
<p>A resource is a named value that is locale-dependent.
For example, your application might have a resource
whose name is <code>"OPEN"</code>
and whose value for an English locale is <code>"Open"</code>
but whose value for a French locale is <code>"Ouvrir"</code>.</p>
<p>A resource bundle is a named group of resources
whose values have been localized for a particular locale.
A resource bundle is identified by the combination of its
<code>bundleName</code> and its <code>locale</code>,
and has a <code>content</code> Object that contains
the name-value pairs for the bundle's resources.</p>
<p>The IResourceBundle interface represents a specific resource bundle.
However, most applications will only need to use IResourceManager.
A single ResourceManager object implementing this interface
manages multiple resource bundles, possibly for multiple locales,
and provides access to the resources that they contain.
For example, you can retrieve a specific resource as a String by calling
<code>resourceManager.getString(bundleName, resourceName)</code>.
By changing the <code>localeChain</code> property of the ResourceManager,
you can change which resource bundles are searched for resource values.</p>
<p>Generally, you do not create resource bundles yourself;
instead, they are usually compiled from *.properties files.
A properties file named MyResources.properties
produces a resource bundle with <code>"MyResources"</code>
for its <code>bundleName</code>.
You generally produce multiple versions of each properties file,
one for each locale that your application supports.</p>
<p>Flex properties files are similar to Java properties files,
except that they also support MXML's <code>Embed()</code>
and <code>ClassReference()</code> directives.
These directives work the same way in a properties file
as they do in a CSS file, producing class references.
Also, the encoding for Flex properties files
is always assumed to be UTF-8.</p>
<p>The Flex framework's resources have been localized
for U.S. English (the <code>"en_US"</code> locale) and
for Japanese (the <code>"ja_JP"</code> locale).
The framework resources are organized into multiple bundles
corresponding to framework packages; for example, the "formatters"
bundle is used by classes in the mx.formatters package.
(There is also a "SharedResources" bundle for resources used by
multiple packages.)</p>
<p>The properties files for the framework resources,
such as formatters.properties, can be found in the
frameworks/projects/framework/bundles/{locale}/src directories
of the Flex SDK.
Your applications normally link against the Flex framework
as a precompiled library, framework.swc,
in the frameworks/libs directory.
This library has no resources in it.
Instead, the framework resources have been compiled into separate
resource bundle libraries such as framework_rb.swc.
These are located in the frameworks/locales/{locale} directories
and your application must also link in one or more of these.</p>
<p>You are free to organize your application's own resources
into whatever bundles you find convenient.
If you localize your application for locales
other than <code>"en_US"</code> and <code>"ja_JP"</code>,
you should localize the framework's properties files for those locales
as well and compile additional resource bundle libaries for them.</p>
<p>When your application starts, the ResourceManager is automatically
populated with whatever resource bundles were compiled
into the application.
If you create a code module, by default the resources that its classes
need are compiled into the module.
When the module is loaded into an application, any bundles that the
application does not already have are added to the ResourceManager.</p>
<p>You can compile "resource modules" that have only resources in them,
and load them with the <code>loadResourceModule()</code> method
of the ResourceManager.
With resource modules, you can support multiple locales by loading
the resources you need at run time rather than compiling them into
your application.</p>
<p>Although the ResourceManager is normally populated with resource bundles
that were compiled into your application or loaded from modules,
you can also programmatically create resource bundles and add them
to the ResourceManager yourself with the <code>addResourceBundle()</code>
method.</p>
<p></p><p><span class="classHeaderTableLabel">See also</span></p><div class="seeAlso"><a href="ResourceBundle.html" target="">mx.resources.ResourceBundle</a><br/><a href="IResourceManager.html" target="">mx.resources.IResourceManager</a><br/><a href="ResourceManager.html" target="">mx.resources.ResourceManager</a></div><br/><hr></div><a name="propertySummary"></a><div class="summarySection"><div class="summaryTableTitle">Public Properties</div><table cellspacing="0" cellpadding="3" class="summaryTable " id="summaryTableProperty"><tr><th>&nbsp;</th><th colspan="2">Property</th><th class="summaryTableOwnerCol">Defined By</th></tr><tr class=""><td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a href="#bundleName" class="signatureLink">bundleName</a> : String<div class="summaryTableDescription">[read-only]
A name that identifies this resource bundle,
such as "MyResources".</div></td><td class="summaryTableOwnerCol">IResourceBundle</td></tr><tr class=""><td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a href="#content" class="signatureLink">content</a> : Object<div class="summaryTableDescription">[read-only]
An object containing key-value pairs for the resources
in this resource bundle.</div></td><td class="summaryTableOwnerCol">IResourceBundle</td></tr><tr class=""><td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol"><a href="#locale" class="signatureLink">locale</a> : String<div class="summaryTableDescription">[read-only]
The locale for which this bundle's resources have been localized.</div></td><td class="summaryTableOwnerCol">IResourceBundle</td></tr></table></div><script language="javascript" type="text/javascript"><!--
showHideInherited();
--></script><div class="MainContent"><div class="detailSectionHeader">Property Detail</div><a name="propertyDetail"></a><a name="bundleName"></a><table class="detailHeader" cellpadding="0" cellspacing="0"><tr><td class="detailHeaderName">bundleName</td><td class="detailHeaderType">property</td></tr></table><div class="detailBody"><code>bundleName:String</code>&nbsp;&nbsp;[read-only] <p></p><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Language Version :&nbsp;</b></td><td>ActionScript 3.0</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Product Version :&nbsp;</b></td><td>Flex 3</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Runtime Versions :&nbsp;</b></td><td>Flash Player 9, AIR 1.1</td></tr></table><p></p><p></p><p>
A name that identifies this resource bundle,
such as <code>"MyResources"</code>.
<p>This read-only property is set
when a resource bundle is constructed.</p>
<p>Resource bundles that are automatically created from compiled
properties files have bundle names based on the names of those files.
For example, a properties file named MyResources.properties
will produce a resource bundle whose <code>bundleName</code>
is <code>"MyResources"</code>.</p>
<p>The ResourceManager can manage multiple bundles with the same
<code>bundleName</code> as long as they have different values
for their <code>locale</code> property.</p>
</p><br/><span class="label"> Implementation </span><br/><code>&nbsp;&nbsp;&nbsp;&nbsp;public function get bundleName():String</code><br/></div><a name="propertyDetail"></a><a name="content"></a><table class="detailHeader" cellpadding="0" cellspacing="0"><tr><td class="detailHeaderName">content</td><td class="detailHeaderType">property</td><td class="detailHeaderRule">&nbsp;</td></tr></table><div class="detailBody"><code>content:Object</code>&nbsp;&nbsp;[read-only] <p></p><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Language Version :&nbsp;</b></td><td>ActionScript 3.0</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Product Version :&nbsp;</b></td><td>Flex 3</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Runtime Versions :&nbsp;</b></td><td>Flash Player 9, AIR 1.1</td></tr></table><p></p><p></p><p>
An object containing key-value pairs for the resources
in this resource bundle.
<p>In general, you should access resources by using IResourceManager
methods such as <code>getString()</code>, rather than directly
accessing them in a resource bundle.
However, if you are programmatically creating your own
resource bundles, you can initialize them with resources,
as follows:</p>
<pre>
var rb:IResourceBundle = new ResourceBundle("fr_FR", "MyResources");
rb.content["LANGUAGE"] = "Francais";
rb.content["GREETING"] = "Bonjour";
</pre>
<p>When a resource bundle is produced by compiling a properties
file, its resource values are either of type String or Class.
For example, if the properties file contains</p>
<pre>
LANGUAGE=English
MINIMUM_AGE=18
ENABLED=true
LOGO=Embed("logo.png")
</pre>
<p>then the value of the <code>LANGUAGE</code> resource
is the String <code>"English"</code>,
the value of the <code>MINIMUM_AGE</code> resource
is the String <code>"18"</code>,
the value of the <code>ENABLED</code> resource
is the String <code>"true"</code>,
and the value of the <code>LOGO</code> resource
is a Class that represents the embedded PNG file.</p>
<p>You can use IResourceManager methods such as <code>getInt()</code>
and <code>getBoolean()</code> to convert resource strings like
<code>"18"</code> and <code>"true"</code> into the type
that your code expects.</p>
</p><br/><span class="label"> Implementation </span><br/><code>&nbsp;&nbsp;&nbsp;&nbsp;public function get content():Object</code><br/></div><a name="propertyDetail"></a><a name="locale"></a><table class="detailHeader" cellpadding="0" cellspacing="0"><tr><td class="detailHeaderName">locale</td><td class="detailHeaderType">property</td><td class="detailHeaderRule">&nbsp;</td></tr></table><div class="detailBody"><code>locale:String</code>&nbsp;&nbsp;[read-only] <p></p><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Language Version :&nbsp;</b></td><td>ActionScript 3.0</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Product Version :&nbsp;</b></td><td>Flex 3</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><tr><td style="white-space:nowrap" valign="top"><b> Runtime Versions :&nbsp;</b></td><td>Flash Player 9, AIR 1.1</td></tr></table><p></p><p></p><p>
The locale for which this bundle's resources have been localized.
This is a String such as <code>"en_US"</code> for U.S. English.
<p>This read-only property is set
when a resource bundle is constructed.</p>
<p>Resource bundles that are automatically created from compiled
properties files have locales based on the
<code>-compiler.locale</code> option of the mxmlc or compc compilers.
For example, suppose that you compile your application with the option
<code>-compiler.locale=en_US,ja_JP</code> and that you have specified
<code>-compiler.source-path=resources/{locale}</code> so that
your application's resources, located in
resources/en_US/MyResources.properties and
resources/ja_JP/MyResources.properties, are found.
Then your application will have two resource bundles
whose <code>bundleName</code> is <code>"MyResources"</code>,
one whose <code>locale</code> is <code>"en_US"</code>
and one whose <code>locale</code> is <code>"ja_JP"</code>.</p>
</p><br/><span class="label"> Implementation </span><br/><code>&nbsp;&nbsp;&nbsp;&nbsp;public function get locale():String</code><br/></div><br/><br/><hr><br/><p></p><center class="copyright"><footer>The Apache Software Foundation</footer><br/>Wed Nov 15 2017, 09:50 AM +01:00 </center></div></body></html><!--The Apache Software Foundation<br/>Wed Nov 15 2017, 09:50 AM +01:00 -->