home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mozil06.zip / bin / chrome / toolkit.jar / content / global / stringbundleBindings.xml < prev    next >
Extensible Markup Language  |  2001-02-14  |  2KB  |  75 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="stringbundle" extends="xul:spring">
  8.     <implementation name="XStringBundle">
  9.       
  10.       <method name="getString">
  11.         <argument name="aStringKey"/>
  12.         <body>
  13.         <![CDATA[
  14.           try {
  15.             return this._bundle.GetStringFromName(aStringKey);
  16.           }
  17.           catch (e) {
  18.             dump("<StringBundle> Error: Failed to get string from bundle. Are you using the right key?\n");
  19.             dump("The key you provided was: " + aStringKey + "\n");
  20.             dump("The exception thrown was:\n" + e + "\n");
  21.           }
  22.         ]]>
  23.         </body>
  24.       </method>
  25.     
  26.       <property name="stringBundle">
  27.         <getter>
  28.         <![CDATA[
  29.           return this._bundle;
  30.         ]]>
  31.         </getter>
  32.         <setter>
  33.         <![CDATA[
  34.           try {
  35.             strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(); 
  36.             strBundleService = strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);
  37.           } 
  38.           catch (ex) {
  39.             return null;
  40.           }
  41.           this._bundle = strBundleService.CreateBundle(val, this.appLocale); 
  42.         ]]>
  43.         </setter>
  44.       </property>
  45.  
  46.       <property name="appLocale">
  47.         <getter>
  48.         <![CDATA[
  49.           var applicationLocale = null;
  50.           try {
  51.             localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"].getService();
  52.             localeService = localeService.QueryInterface(Components.interfaces.nsILocaleService);
  53.           } 
  54.           catch (ex) {
  55.             return null;
  56.           }
  57.           applicationLocale = localeService.GetApplicationLocale();
  58.           return applicationLocale;
  59.         ]]>
  60.         </getter>
  61.       </property>
  62.  
  63.       <property name="_bundle"/>
  64.     </implementation>
  65.     <handlers>
  66.       <handler event="bindingattached">
  67.       <![CDATA[
  68.         this.stringBundle = this.getAttribute("src");
  69.       ]]>
  70.       </handler>
  71.     </handlers>
  72.   </binding>
  73.   
  74. </bindings>          
  75.