Gadgets and Message Bundles

Currently NOT to USE!!!!!!!!!

 


 

Phase 3.2 Internationalization

The ideal of the internationalization is two fold in Gadgets and Message Bundles for Internationalization

  • Software that senses the language of browser (English, Hindi, Spanish,etc) and picks up the corresponding language content for delivery and displays it.
  • Probably this will include some special (xml?) markup of your source code for your entrance page text content ---so it gets the correct language content -- AND the main navigation bar.
  • A probably diffferent tool will be used to take your English content and translate it into at least 2 other languages which must include spanish.

 

Take a look at (http://code.google.com/apis/gadgets/docs/i18n.html#Hello_World) for information on google about this process.

 

Example

Once you have done the translation, you will have a series of message bundle files like the following for english, spanish and hindi:

en_ALL.xml file

<?xml version="1.0" encoding="utf-8" ?>
<messagebundle>
<msg name='home'><![CDATA[Home]]></msg>
<msg name='byAge'><![CDATA[By Age]]></msg>
<msg name='byBrand'><![CDATA[By Brand]]></msg>
<msg name='viewCart'><![CDATA[View Cart]]></msg>
<msg name='orderPage'><![CDATA[Order Page]]></msg>
<msg name='login'><![CDATA[Login]]></msg>
<msg name='logout'><![CDATA[Logout]]></msg>
</messagebundle>

es_ALL.xml file

<?xml version="1.0" encoding="utf-8" ?>
<messagebundle>
<msg name='home'><![CDATA[Inicio]]></msg>
<msg name='byAge'><![CDATA[Por edad]]></msg>
<msg name='byBrand'><![CDATA[Por marca]]></msg>
<msg name='viewCart'><![CDATA[Ver carrito]]></msg>
<msg name='orderPage'><![CDATA[Orden]]></msg>
<msg name='login'><![CDATA[Inicio de sesión]]></msg>
<msg name='logout'><![CDATA[Cerrar sesión]]></msg>
</messagebundle>

 

hi_ALL.xml

<?xml version="1.0" encoding="utf-8" ?>
<messagebundle>
<msg name='home'><![CDATA[à¤\230र]]></msg>
<msg name='byAge'><![CDATA[à¤\206यà¥\201 तà¤\225]]></msg>
<msg name='byBrand'><![CDATA[बà¥\215राà¤\202ड सà¥\207]]></msg>
<msg name='viewCart'><![CDATA[दà¥\207à¤\226à¥\207à¤\202 à¤\225ारà¥\215à¤\2
37]]></msg>
<msg name='orderPage'><![CDATA[à¤\206दà¥\207श पà¥\203षà¥\215ठ]]></msg>
<msg name='login'><![CDATA[लà¥\211à¤\227 à¤\207न]]></msg>
<msg name='logout'><![CDATA[लà¥\211à¤\227à¤\206à¤\211à¤\237]]></msg>
</messagebundle>

 

Next you will need to create an XML gadget file that uses them as follows. Now this gadget is using only one of the 7 messages defined in the bundles above, the message called "home" and is references below as __MSG_home__

a.xml

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="PHP Userprefs">
<Locale lang="en" messages="http://puzzle.mcs.csueastbay.edu/~gr
ewe/gadget/en_ALL.xml"/>
<Locale lang="es" messages="http://puzzle.mcs.csueastbay.edu/~gr
ewe/gadget/es_ALL.xml"/>
<Locale lang="hi" messages="http://puzzle.mcs.csueastbay.edu/~gr
ewe/gadget/hi_ALL.xml"/>
</ModulePrefs>
<Content type="html">
<![CDATA[

<div id='heading'></div>
<hr size="1px"/>
<div id='main'></div>
<hr >
<div id='friends'></div>
<div id='friend_status'> </div>

 

My __MSG_home__ is good

 

]]>
</Content>
</Module>

 

Now for your website to use this XML gadget you need to "serve" the gadget through a Gadget container. Google provides one for you with iGoogle and gmodules. You can use the XML file (above called a.xml) as follows in an html file via the following JavaScript. Note that YOU MUST alter the JavaScript to point to your URL for YOUR xml gadget file on the course server. If you have any problems make sure the the gmodules link is still valid. An alternative to this is to host your gadget (in published form) off of iGoogle. See

<html>
<head>
</head>
<body>
<script src="http://www.gmodules.com/ig/ifr?url=http://puzzle.mcs.csueastbay.edu
/~grewe/gadget/a.xml
&amp;output=js"></script>

</body>
</html>

 

VERY IMPORTANT....

there is an issue of caching as you are testing your html code and you change the language preference in your browser you will need to remove the cache, removing all offsite web data, so that when you then hit the reload button on your browser it will not serve a cached page to you but, rather use the language preference to select the correct message bundle file.

This is what the above looks like when I am running this with "Spanish" as my language:

gadget running

Unfortunately we are currently stuck with the frame around the gadget as it is being served through gmodules (google) and they put this on for advertisement sake. However, if you are doing this for an OpenSocial app container you will not see this artificial boundary.

 


© Lynne Grewe