home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 October / Gamestar_77_2005-10_dvd.iso / Programy / nsb-install-8-0.exe / chrome / toolkit.jar / content / global / bindings / stringbundle.xml < prev    next >
Extensible Markup Language  |  2005-07-29  |  3KB  |  98 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 get 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.       <field name="_bundle">null</field>
  93.  
  94.     </implementation>
  95.   </binding>
  96.  
  97. </bindings>
  98.