home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 May / PCWorld_2003-05_cd.bin / Komunik / phoenix / chrome / toolkit.jar / content / global / widgets / stringbundle.xml < prev    next >
Extensible Markup Language  |  2002-10-13  |  2KB  |  86 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings id="stringBundleBindings"
  4.           xmlns="http://www.mozilla.org/xbl"
  5.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  6.  
  7.   <binding id="stringbundleset" extends="xul:box"/>
  8.  
  9.   <binding id="stringbundle" extends="xul:spacer">
  10.     <implementation name="XStringBundle">
  11.  
  12.       <method name="getString">
  13.         <parameter name="aStringKey"/>
  14.         <body>
  15.           <![CDATA[
  16.             return this.stringBundle.GetStringFromName(aStringKey);
  17.           ]]>
  18.         </body>
  19.       </method>
  20.  
  21.       <method name="getFormattedString">
  22.         <parameter name="aStringKey"/>
  23.         <parameter name="aStringsArray"/>
  24.         <body>
  25.           <![CDATA[
  26.             return this.stringBundle.formatStringFromName(aStringKey, aStringsArray, aStringsArray.length);
  27.           ]]>
  28.         </body>
  29.       </method>
  30.  
  31.       <property name="stringBundle" readonly="true">
  32.         <getter>
  33.           <![CDATA[
  34.             if (!this._bundle) {
  35.               try {
  36.                 var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  37.                                                     .getService(Components.interfaces.nsIStringBundleService);
  38.                 this._bundle = stringBundleService.createBundle(this.src, this.appLocale);
  39.               }
  40.               catch (e) {
  41.                 dump("Failed to get stringbundle:\n");
  42.                 dump(e + "\n");
  43.               }
  44.             }
  45.             return this._bundle;
  46.           ]]>
  47.         </getter>
  48.       </property>
  49.  
  50.       <property name="src">
  51.         <getter>
  52.           <![CDATA[
  53.             return this.getAttribute("src");
  54.           ]]>
  55.         </getter>
  56.         <setter>
  57.           <![CDATA[
  58.             this._bundle = null;
  59.             this.setAttribute("src", val);
  60.             return val;
  61.           ]]>
  62.         </setter>
  63.       </property>
  64.  
  65.       <property name="appLocale">
  66.         <getter>
  67.           <![CDATA[
  68.             try {
  69.               var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
  70.                                             .getService(Components.interfaces.nsILocaleService);
  71.               return localeService.GetApplicationLocale();
  72.             }
  73.             catch (ex) {
  74.               return null;
  75.             }
  76.           ]]>
  77.         </getter>
  78.       </property>
  79.  
  80.       <field name="_bundle">null</field>
  81.  
  82.     </implementation>
  83.   </binding>
  84.  
  85. </bindings>
  86.