|
|
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']='Sell Your House';
jsL10N['menu_SellerAdvertise']='Advertise Your House';
jsL10N['menu_SellerManageBids']='Manage Your Bids';
jsL10N['menu_SellerFAQs']='Home Seller FAQs';
jsL10N['menu_InvestorMain']='Home Investors';
jsL10N['menu_InvestorRegister']='Register With Us';
jsL10N['menu_InvestorUpdate']='Update Your Profile';
jsL10N['menu_InvestorFAQs']='Home Investor FAQs';
jsL10N['menu_FAQsMain']='FAQs';
jsL10N['menu_ContactUsMain']='Contact Us';
//-->
</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: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx
|
|