I ended up writing my own component to localize some key values in javascript.
I have a persistent menu living in the Border component I created that all my pages use.
The menu has localized selections on it.
The initialization of the menu (3rd party), sets up the text to go in the menu entries in the javascript.


Wasn't sure if there was an easier way, but I wrote a component that, given the following tag in a HEAD element (or anywhere on the page, really) :

<script  jwcid="@L10NScript" language="JavaScript1.2"
   type="text/javascript"
   keys="menu_SellerMain,
           menu_SellerAdvertise,
           menu_SellerManageBids,
           menu_SellerFAQs,
           menu_InvestorMain,
           menu_InvestorRegister,
           menu_InvestorUpdate,
           menu_InvestorFAQs,
           menu_FAQsMain,
           menu_ContactUsMain"></script>

Takes the keys in the "keys" array, localizes them, and produces the following JavaScript :

  <script language="JavaScript1.2" type="text/javascript">
    <!--

    if(typeof jsL10N == 'undefined')
    {
      var jsL10N = new Array();
    }

    function getL10N(key)
    {
      var value = jsL10N[key];
      if(typeof value=='undefined')
      {
        value = '[' + key + ']';
      }
      return unescape(value);
    };

    
jsL10N['menu_SellerMain']='&#83;&#101;&#108;&#108;&#32;&#89;&#111;&#117;&#114;&#32;&#72;&#111;&#117;&#115;&#101;';
    
jsL10N['menu_SellerAdvertise']='&#65;&#100;&#118;&#101;&#114;&#116;&#105;&#115;&#101;&#32;&#89;&#111;&#117;&#114;&#32;&#72;&#111;&#117;&#115;&#101;';
    
jsL10N['menu_SellerManageBids']='&#77;&#97;&#110;&#97;&#103;&#101;&#32;&#89;&#111;&#117;&#114;&#32;&#66;&#105;&#100;&#115;';
    
jsL10N['menu_SellerFAQs']='&#72;&#111;&#109;&#101;&#32;&#83;&#101;&#108;&#108;&#101;&#114;&#32;&#70;&#65;&#81;&#115;';
    
jsL10N['menu_InvestorMain']='&#72;&#111;&#109;&#101;&#32;&#73;&#110;&#118;&#101;&#115;&#116;&#111;&#114;&#115;';
    
jsL10N['menu_InvestorRegister']='&#82;&#101;&#103;&#105;&#115;&#116;&#101;&#114;&#32;&#87;&#105;&#116;&#104;&#32;&#85;&#115;';
    
jsL10N['menu_InvestorUpdate']='&#85;&#112;&#100;&#97;&#116;&#101;&#32;&#89;&#111;&#117;&#114;&#32;&#80;&#114;&#111;&#102;&#105;&#108;&#101;';
    
jsL10N['menu_InvestorFAQs']='&#72;&#111;&#109;&#101;&#32;&#73;&#110;&#118;&#101;&#115;&#116;&#111;&#114;&#32;&#70;&#65;&#81;&#115;';
    jsL10N['menu_FAQsMain']='&#70;&#65;&#81;&#115;';
    
jsL10N['menu_ContactUsMain']='&#67;&#111;&#110;&#116;&#97;&#99;&#116;&#32;&#85;&#115;';

    //-->
  </script>


So script clients need only call getL10N('someKey') to get the localization for that key.
The value itself is UTF-8 and html character entity encoded to eliminate any problems with special characters, escape sequences, etc. that can mess the javascript up.


Does anyone see any problems with this approach, or could suggest one that's already been done that may be better ?

Thanks in advance,
tappapp


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to