?? bistringbundle.html
字號:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><!--
Generated using api.website.xsl version 2003-07-17
-->
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BiStringBundle</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type="text/css" rel="stylesheet" href="api.css"><script type="text/javascript">
function showDerivedClasses() {
var ul = document.getElementById("api-derived-classes");
var lis = ul.childNodes;
var l = lis.length;
for (var i = 1; i < l; i++)
lis[i].style.display = "";
lis[0].style.display = "none";
}
</script></head>
<body>
<h1 id="BiStringBundle">BiStringBundle</h1>
<p>
This class is used to make creating multilingual applications easier.
The string bundle is uses one hash table (objects in JavaScript) for
every language and falls back on English (<code>"en"</code>) in case the
user language is not available.
</p>
<p>This class extends
<code><a href="BiEventTarget.html">BiEventTarget</a></code>
and therefore all methods and fields available for
<code><a href="BiEventTarget.html">BiEventTarget</a></code>
are also available for <code>BiStringBundle</code>.</p>
<ul class="partial-class-tree">
<li><code><a href="BiObject.html">BiObject</a></code><ul>
<li><code><a href="BiEventTarget.html">BiEventTarget</a></code><ul><li><code>BiStringBundle</code><ul id="api-derived-classes"></ul></li></ul></li></ul>
</li>
</ul>
<h2>Constructor</h2>
<p><code>
new BiStringBundle()</code></p>
<h3>Parameters</h3>
<p>No parameters.</p>
<h2>Properties</h2>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="get-header">get</td>
<td class="set-header">set</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><a name="bundles"></a><code>bundles</code></td>
<td><code class="type">Object[]</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"></td>
<td>Returns the added bundles as an array</td>
</tr>
<tr>
<td><a name="language"></a><code>language</code></td>
<td><code class="type">String</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"><img src="check.png" alt="checked"></td>
<td>The current language</td>
</tr>
<tr>
<td><a name="majorLanguage"></a><code>majorLanguage</code></td>
<td><code class="type">String</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"></td>
<td>The current major language</td>
</tr>
<tr>
<td><a name="userLanguage"></a><code>userLanguage</code></td>
<td><code class="type">String</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"></td>
<td>The language of the user's operating environment</td>
</tr>
</tbody>
</table>
<h2>Methods</h2>
<table>
<thead>
<tr>
<td>Name</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="#addBundle">addBundle</a></code></td>
<td>Adds a bundle and associates that with a certain language code</td>
</tr>
<tr>
<td><code><a href="#getBundleForLanguage">getBundleForLanguage</a></code></td>
<td>Returns the bundle (hash table) for the given language code</td>
</tr>
<tr>
<td><code><a href="#getString">getString</a></code></td>
<td>Returns the string for the given string id. The second argument is the language
code to get the string for. If left out then the current language for the string bundle
is used.
</td>
</tr>
<tr>
<td><code><a href="#removeBundle">removeBundle</a></code></td>
<td>Removes the string bundle with the given language code</td>
</tr>
</tbody>
</table>
<h2>Events</h2>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="bubbles-header">Bubbles</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><a name="change"></a><code>change</code></td>
<td><code class="type"><code><a href="BiEvent.html">BiEvent</a></code></code></td>
<td class="bubbles-column"></td>
<td>This event is fired when the current strings changes in some way.
This happens when the language is changed or a new bundle is added with the current language.</td>
</tr>
</tbody>
</table>
<h2>Static Methods</h2>
<p>None.</p>
<h2>Static Fields</h2>
<p>None.</p>
<h2>Remarks</h2>
<p>
The string bundles (that are added using <code><a href="#addBundle">addBundle</a></code> should be
plain JavaScript objects (hash tables) with the following form:<br>
<br>
<code>var enBundle = {<br>
languageCode: "en",<br>
languageName: "English",<br>
selectLanguage: "Select Language:",<br>
checkingForIsLoggedIn: "Checking if already logged in...",<br>
windowCaption: "Download the Bindows\u2122 Framework"<br>
};</code><br>
<br>
The languageCode and languageName fields are not special in any way. It is just
a good practice to include them and they are often useful to the application.<br>
<br>
Typical usage looks something like this:<br>
<br>
<code>var stringBundle = new BiStringBundle;<br>
stringBundle.addBundle("en", enBundle);<br>
...<br>
someLabel.setText( stringBundle.getString("someLabelText") );</code>
</p>
<h2>Method Details</h2>
<h3><a name="addBundle"></a>addBundle</h3>
<p>Adds a bundle and associates that with a certain language code</p>
<h4>Syntax</h4>
<pre class="method-syntax">object.addBundle(<span class="methodArgument">sLanguage</span>, <span class="methodArgument">oStringMap</span>)</pre>
<h4>Parameters</h4>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="optional-header">Optional</td>
<td>Default</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>sLanguage</code></td>
<td><code class="type">String</code></td>
<td class="optional-column"></td>
<td></td>
<td>The language code for the string bundle to add.</td>
</tr>
<tr>
<td><code>oStringMap</code></td>
<td><code class="type">Object</code></td>
<td class="optional-column"></td>
<td></td>
<td>The hash table used to map string identifiers to strings.</td>
</tr>
</tbody>
</table>
<h4>Return Type</h4>
<p><code class="type">void</code></p>
<h3><a name="getBundleForLanguage"></a>getBundleForLanguage</h3>
<p>Returns the bundle (hash table) for the given language code</p>
<h4>Syntax</h4>
<pre class="method-syntax">object.getBundleForLanguage(<span class="methodArgument">sLanguage</span>)</pre>
<h4>Parameters</h4>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="optional-header">Optional</td>
<td>Default</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>sLanguage</code></td>
<td><code class="type">String</code></td>
<td class="optional-column"></td>
<td></td>
<td>The language code of the string bundle to return</td>
</tr>
</tbody>
</table>
<h4>Return Type</h4>
<p><code class="type">Object</code></p>
<h3><a name="getString"></a>getString</h3>
<p>Returns the string for the given string id. The second argument is the language
code to get the string for. If left out then the current language for the string bundle
is used.
</p>
<h4>Syntax</h4>
<pre class="method-syntax">object.getString(<span class="methodArgument">sStringId</span> [, <span class="methodArgument">sLanguage</span>])</pre>
<h4>Parameters</h4>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="optional-header">Optional</td>
<td>Default</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>sStringId</code></td>
<td><code class="type">String</code></td>
<td class="optional-column"></td>
<td></td>
<td>The id for the string to retreive</td>
</tr>
<tr>
<td><code>sLanguage</code></td>
<td><code class="type">String</code></td>
<td class="optional-column"><img src="check.png" alt="checked"></td>
<td></td>
<td>The language code of the string to return</td>
</tr>
</tbody>
</table>
<h4>Return Type</h4>
<p><code class="type">String</code></p>
<h3><a name="removeBundle"></a>removeBundle</h3>
<p>Removes the string bundle with the given language code</p>
<h4>Syntax</h4>
<pre class="method-syntax">object.removeBundle(<span class="methodArgument">sLanguage</span>)</pre>
<h4>Parameters</h4>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="optional-header">Optional</td>
<td>Default</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>sLanguage</code></td>
<td><code class="type">String</code></td>
<td class="optional-column"></td>
<td></td>
<td>The language code of the string bundle to remove</td>
</tr>
</tbody>
</table>
<h4>Return Type</h4>
<p><code class="type">void</code></p>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -