bistringbundle.xml
来自「ajax 框价.是个好工具.javascript 矿家.可以用在任何平台.」· XML 代码 · 共 218 行
XML
218 行
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="api.xsl"?><class name="BiStringBundle" extends="BiEventTarget"> <description>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.</description> <arguments> </arguments> <staticMethods> <method name="formatString"> <description>Takes a string containing %1 to %n and 0 to n extra arguments that will replace the %n strings.</description> <arguments> <argument name="sPattern"> <description>A string containing '%n' where '%n' will be replaced by the remaining arguments.</description> <type>String</type> </argument> <argument name="args" optional="true"> <description>Optional arguments (as many as you wish) that will replace the '%n' in the pattern</description> <type>String</type> </argument> </arguments> <returns> <type>String</type> </returns> </method> </staticMethods> <staticFields> </staticFields> <methods> <method name="getStringKeys"> <description>Returns the keys used to identify the strings in the bundles</description> <arguments> <argument name="sLanguage" optional="true"> <description>The language code to use when getting the strings in the bundle. If left out the current language is is used</description> <type>String</type> </argument> </arguments> <returns> <type>String[]</type> </returns> </method> <method name="getString"> <description>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.</description> <arguments> <argument name="sStringId"> <description>The id for the string to retreive</description> <type>String</type> </argument> <argument name="sLanguage" optional="true"> <description>The language code of the string to return </description> <type>String</type> </argument> </arguments> <returns> <type>String</type> </returns> </method> <method name="getFormattedString"> <description>Returns the string for the given string id. The string is then formatted so that %1 to %n are replaced by the extra arguments to this method. This method does not allow you to specify the language. If that is needed use <link>getString</link> followed by <link>formatString</link>.</description> <arguments> <argument name="sStringId"> <description>The id for the string to retreive</description> <type>String</type> </argument> <argument name="args" optional="true"> <description>Optional arguments (as many as you wish) that will replace the '%n' in the pattern</description> <type>String</type> </argument> </arguments> <returns> <type>String</type> </returns> </method> <method name="addBundle"> <description>Adds a bundle and associates that with a certain language code</description> <arguments> <argument name="sLanguage"> <description>The language code for the string bundle to add.</description> <type>String</type> </argument> <argument name="oStringMap"> <description>The hash table used to map string identifiers to strings.</description> <type>Object</type> </argument> </arguments> <returns> <type>void</type> </returns> </method> <method name="appendBundle"> <description>This adds key value pairs to an existing bundle. This allows you to modify an existing bundle with more strings</description> <arguments> <argument name="sLanguage"> <description>The language code for the string bundle to append.</description> <type>String</type> </argument> <argument name="oStringMap"> <description>The hash table used to map string identifiers to strings.</description> <type>Object</type> </argument> </arguments> <returns> <type>void</type> </returns> </method> <method name="removeBundle"> <description>Removes the string bundle with the given language code</description> <arguments> <argument name="sLanguage"> <description>The language code of the string bundle to remove</description> <type>String</type> </argument> </arguments> <returns> <type>void</type> </returns> </method> <method name="getBundleForLanguage"> <description>Returns the bundle (hash table) for the given language code. This will return the best match. If you pass "zh-cn" it will try to find the bundles in the following order; "zh-cn", "zh", <link>language</link>, <link>majorLanguage</link>, "en" and if all these fails an empty bundle (object) will be returned.</description> <arguments> <argument name="sLanguage" optional="true"> <description>The language code of the string bundle to return. If left out the default language is used.</description> <type>String</type> </argument> </arguments> <returns> <type>Object</type> </returns> </method> </methods> <properties> <property name="language" get="true" set="true"> <description>The current language</description> <type>String</type> </property> <property name="languages" get="true"> <description>Returns the languages supported by the string bundle</description> <type>String[]</type> </property> <property name="majorLanguage" get="true"> <description>The current major language. For example if the current language is <code>"en-us"</code> then this returns <code>"en"</code>.</description> <type>String</type> </property> <property name="userLanguage" get="true"> <description>The language of the user's operating environment</description> <type>String</type> </property> <property name="bundles" get="true"> <description>Returns the added bundles as an array</description> <type>Object[]</type> </property> </properties> <events> <event name="change"> <description>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.</description> <type> <link class="BiEvent">BiEvent</link> </type> </event> </events> <remarks>The string bundles (that are added using <link>addBundle</link> should be plain JavaScript objects (hash tables) with the following form:<br> </br> <br> </br> <code>var enBundle = {<br> </br> languageCode: "en",<br> </br> languageName: "English",<br> </br> selectLanguage: "Select Language:",<br> </br> checkingForIsLoggedIn: "Checking if already logged in...",<br> </br> windowCaption: "Download the Bindows\u2122 Framework"<br> </br> };</code> <br> </br> <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> <br> </br> Typical usage looks something like this:<br> </br> <br> </br> <code>var stringBundle = new<link class="BiStringBundle">BiStringBundle</link>;<br> </br> stringBundle.addBundle("en", enBundle);<br> </br> ...<br> </br> someLabel.setText( stringBundle.getString("someLabelText") );</code> </remarks></class>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?