home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / toolkit.jar / content / global / bindings / stringbundle.xml < prev    next >
Encoding:
Extensible Markup Language  |  2005-02-25  |  3.1 KB  |  108 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.             try {
  17.               return this.stringBundle.GetStringFromName(aStringKey);
  18.             }
  19.             catch (e) {
  20.               dump("*** Failed to get string " + aStringKey + " in bundle: " + this.src + "\n");
  21.               throw e;
  22.             }
  23.           ]]>
  24.         </body>
  25.       </method>
  26.  
  27.       <method name="getFormattedString">
  28.         <parameter name="aStringKey"/>
  29.         <parameter name="aStringsArray"/>
  30.         <body>
  31.           <![CDATA[
  32.             try {
  33.               return this.stringBundle.formatStringFromName(aStringKey, aStringsArray, aStringsArray.length);
  34.             }
  35.             catch (e) {
  36.               dump("*** Failed to format string " + aStringKey + " in bundle: " + this.src + "\n");
  37.               throw e;
  38.             }
  39.           ]]>
  40.         </body>
  41.       </method>
  42.  
  43.       <property name="stringBundle" readonly="true">
  44.         <getter>
  45.           <![CDATA[
  46.             if (!this._bundle) {
  47.               try {
  48.                 var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  49.                                                     .getService(Components.interfaces.nsIStringBundleService);
  50.                 this._bundle = stringBundleService.createBundle(this.src, this.appLocale);
  51.               }
  52.               catch (e) {
  53.                 dump("Failed to get stringbundle:\n");
  54.                 dump(e + "\n");
  55.               }
  56.             }
  57.             return this._bundle;
  58.           ]]>
  59.         </getter>
  60.       </property>
  61.  
  62.       <property name="src">
  63.         <getter>
  64.           <![CDATA[
  65.             return this.getAttribute("src");
  66.           ]]>
  67.         </getter>
  68.         <setter>
  69.           <![CDATA[
  70.             this._bundle = null;
  71.             this.setAttribute("src", val);
  72.             return val;
  73.           ]]>
  74.         </setter>
  75.       </property>
  76.  
  77.       <property name="appLocale">
  78.         <getter>
  79.           <![CDATA[
  80.             try {
  81.               var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
  82.                                             .getService(Components.interfaces.nsILocaleService);
  83.               return localeService.getApplicationLocale();
  84.             }
  85.             catch (ex) {
  86.               return null;
  87.             }
  88.           ]]>
  89.         </getter>
  90.       </property>
  91.       
  92.       <property name="strings">
  93.         <getter>
  94.           <![CDATA[
  95.             // Note: this is a sucky method name! Should be:
  96.             //       readonly attribute nsISimpleEnumerator strings;
  97.             return this.stringBundle.getSimpleEnumeration();
  98.           ]]>
  99.         </getter>
  100.       </property>
  101.  
  102.       <field name="_bundle">null</field>
  103.  
  104.     </implementation>
  105.   </binding>
  106.  
  107. </bindings>
  108.