<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>BlackBerry Developer Blog &#187; internationalization</title>
	<atom:link href="http://devblog.blackberry.com/tag/internationalization/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.blackberry.com</link>
	<description></description>
	<lastBuildDate>Tue, 18 Jun 2013 16:50:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='devblog.blackberry.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/9ef0a66c09615fa946c4179662398878?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>BlackBerry Developer Blog &#187; internationalization</title>
		<link>http://devblog.blackberry.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://devblog.blackberry.com/osd.xml" title="BlackBerry Developer Blog" />
	<atom:link rel='hub' href='http://devblog.blackberry.com/?pushpress=hub'/>
		<item>
		<title>Best Practices for Internationalizing your BlackBerry WebWorks App</title>
		<link>http://devblog.blackberry.com/2012/06/internationalizing-webworks-app/</link>
		<comments>http://devblog.blackberry.com/2012/06/internationalizing-webworks-app/#comments</comments>
		<pubDate>Mon, 18 Jun 2012 14:09:53 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[Java Development]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[blackberry webworks]]></category>
		<category><![CDATA[internationalization]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[sample code]]></category>
		<category><![CDATA[texts]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=9764</guid>
		<description><![CDATA[Demonstrating the best ways to internationalize your BlackBerry WebWorks application.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9764&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:center;"><img class="aligncenter size-full wp-image-9769" src="http://rimdevblog.files.wordpress.com/2012/06/webworks.jpg?w=550&#038;h=255" alt="TITLE_IMAGE" width="550" height="255" /></p>
<p>Last month, we looked at <a href="http://devblog.blackberry.com/2012/05/app-internationalization" target="_new">how to internationalize your BlackBerry® Java® application</a>. In this post, we will look at how to internationalize your BlackBerry® WebWorks™ application. There are a few options for accomplishing this – let’s take a look.</p>
<h3><strong>Using JavaScript and storing all the texts locally</strong></h3>
<p>One common way to internationalize your web application is to remove all strings from your code and have them all in an object with key-value pairs. All the code exists locally and nothings get stored on the server side.</p>
<p>This looks something like:</p>
<pre>var strings = {
	"en" : {
		"BUTTON_CANCEL" : "Cancel",
		"BUTTON_SAVE" : "Save"
	},
	nl: {
		"BUTTON_CANCEL" : "Annuleer",
		"BUTTON_SAVE" : "Opslaan"
	}
}</pre>
<p>Now let&#8217;s assume you keep the chosen language somewhere in a variable called language. You can then access the right string for the user language, like with the cancel button text for example:</p>
<p>Strings[language].BUTTON_CANCEL</p>
<p>That will give you either &#8216;Cancel&#8217; or &#8216;Annuleer&#8217; depending on whether the language variable contains &#8216;en&#8217; or &#8216;nl&#8217;.</p>
<p><span id="more-9764"></span></p>
<h3><strong>Using JavaScript and storing all the texts on a remote server</strong></h3>
<p>Another way of internationalizing your application in BlackBerry WebWorks platform is to use the server side code. Unfortunately, JavaScript does not have the concept of a resource file, and strings that will be generated by JavaScript must be defined in the code.</p>
<p>The easiest approach to deal with this issue is to define your JavaScript strings dynamically in server-side code (Java/JSP, ASPX, PHP, etc.). The following example defines some string resources in a JavaScript script block at the top of a JSP page:</p>
<p><img class="alignnone size-full wp-image-9768" title="" src="http://rimdevblog.files.wordpress.com/2012/06/webworks-1.jpg?w=600&#038;h=142" alt="" width="600" height="142" /></p>
<p>Assuming the currentLocale object is set to English (US), the resulting block should look like this:</p>
<p><img class="alignnone size-full wp-image-9767" title="" src="http://rimdevblog.files.wordpress.com/2012/06/webworks-2.jpg?w=600&#038;h=216" alt="" width="600" height="216" /></p>
<p>When currentLocale is set to German (Germany) it should change to this:</p>
<p><img class="alignnone size-full wp-image-9766" title="" src="http://rimdevblog.files.wordpress.com/2012/06/webworks-3.jpg?w=600&#038;h=195" alt="" width="600" height="195" /></p>
<p>There are a couple things to keep in mind with this approach. First, any strings that are embedded in the files, whether JSP/ASPX/PHP/etc. or JavaScript .js files, must be externalized, i.e. the strings should be moved into the string resource block as demonstrated above, and replaced in the code with their variable names. Second, the JavaScript string resource block should be defined before any other embedded blocks or .js file includes that make use of these externalized strings. For example, the resource block should be defined before the following function is called:</p>
<p><img class="alignnone size-full wp-image-9765" title="" src="http://rimdevblog.files.wordpress.com/2012/06/webworks-4.jpg?w=500&#038;h=272" alt="" width="500" height="272" /></p>
<h3><strong>Using JavaScript Object Notation (JSON)</strong></h3>
<p>Finally, another way to add multi-language support to your BlackBerry WebWorks application is to use JSON objects. Here is a sample which illustrates the use of JSON objects and changes the text dynamically based on the user’s language selection:</p>
<pre>&lt;html&gt;
&lt;body&gt;
&lt;h2&gt;Internationalization Sample in WebWorks&lt;/h2&gt;
&lt;h3&gt;Select a language:&lt;/h3&gt;
&lt;p&gt;

&lt;select id="languagechoice" onChange="displayGreeting()" &gt;
  &lt;option value="1"&gt;English&lt;/option&gt;
  &lt;option value="2"&gt;French&lt;/option&gt;
  &lt;option value="3"&gt;Spanish&lt;/option&gt;
  &lt;option value="4"&gt;German&lt;/option&gt;
&lt;/select&gt;

&lt;br/&gt; 
&lt;br/&gt;
&lt;br/&gt;

 &lt;span id="greetings"&gt;&lt;/span&gt; &lt;br/&gt;
&lt;/p&gt;

&lt;script type="text/javascript"&gt;

function displayGreeting(){

 var lang = document.getElementById("languagechoice");
 var lang_value = lang.options[lang.selectedIndex].value; 

 var JSONObject_en = {"hello":"Hello, Welcome to Internalization of WebWorks Applications in English!"};
 var JSONObject_fr = {"hello":"Hello, Welcome to Internalization of WebWorks Applications in French!"};
 var JSONObject_es = {"hello":"Hello, Welcome to Internalization of WebWorks Applications in Spanish!"};
 var JSONObject_de = {"hello":"Hello, Welcome to Internalization of WebWorks Applications in German!"};

 if(lang_value == 1){
   document.getElementById("greetings").innerHTML=JSONObject_en.hello 
 }
 else if (lang_value == 2 ){
   document.getElementById("greetings").innerHTML=JSONObject_fr.hello
 }
 else if (lang_value == 3 ){
   document.getElementById("greetings").innerHTML=JSONObject_es.hello
 }
 else{
   document.getElementById("greetings").innerHTML=JSONObject_de   .hello
 }
}

&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/9764/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/9764/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9764&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/06/internationalizing-webworks-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/83a3304d7f99cd7e5d2323b7338f7305?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">naveenm1</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/06/webworks.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/06/webworks-1.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/06/webworks-2.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/06/webworks-3.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/06/webworks-4.jpg" medium="image" />
	</item>
		<item>
		<title>BlackBerry App Internationalization: Language, currency and address support</title>
		<link>http://devblog.blackberry.com/2012/05/app-internationalization/</link>
		<comments>http://devblog.blackberry.com/2012/05/app-internationalization/#comments</comments>
		<pubDate>Thu, 31 May 2012 14:49:41 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[internationalization]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[localized]]></category>
		<category><![CDATA[sample code]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=9641</guid>
		<description><![CDATA[How to localize a simple app on the BlackBerry platform.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9641&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Did you know that you can internationalize your BlackBerry® application using the JSR 238? More specifically, you can do the following to your BlackBerry application so that your app is ready for the international market:</p>
<ul>
<li>Multiple language support</li>
<li>Localization of currency</li>
<li>Localization of addresses</li>
<li>Detecting which country the user is located in (in the event that you have certain content that you only have license to serve in certain geographies)</li>
</ul>
<p>In this blog post, we will look at the multiple language support in detail – the rest of the above topics will be covered in upcoming blog posts here on the Inside BlackBerry Developer’s Blog.</p>
<p><span id="more-9641"></span></p>
<p>All commercial applications these days should be localized, and BlackBerry uses net.rim.device.api.i18n package to enable seamless localization.</p>
<p>If your application is localized, it will be displayed in the local language out of the box. So if the default locale settings on one device are set to English and French on the other, the application will be displayed in the correct language on both devices without any need for interaction from the user.</p>
<h3><strong>Setting up a New BlackBerry Project</strong></h3>
<p>This blog post assumes that you should already know how to set up and configure a new BlackBerry project in Eclipse™. If you need a reminder, refer to this <a href="http://supportforums.blackberry.com/t5/Java-Development/Writing-Your-First-Application/ta-p/442771" target="_new">link</a>.</p>
<p>Here is a sample code to show how to localize a simple application:</p>
<p><code>package com.rim.samples.local;</p>
<p>import net.rim.device.api.ui.MenuItem; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.i18n.*;</p>
<p>public class Local extends UiApplication {<br />
public static void main(String[] args) { Local theApp = new Local();</p>
<p>theApp.enterEventDispatcher();<br />
}</p>
<p>public Local() {<br />
pushScreen(new LocalScreen());<br />
}<br />
}</p>
<p>final class LocalScreen extends MainScreen implements LocalDemoResource {</p>
<p>private static ResourceBundle _res = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);<br />
LabelField title;<br />
RichTextField rtf;</p>
<p>public LocalScreen() {<br />
super();<br />
title	=	new	LabelField(_res.getString(FIELD_TITLE), LabelField.ELLIPSIS| LabelField.USE_ALL_WIDTH);<br />
setTitle(title);<br />
rtf = new RichTextField(_res.getString(MESSAGE));<br />
add(rtf);<br />
}</code></p>
<p>If you read the code carefully, you will notice that our LocalScreen class implements LocalDemoResource. Also new is the ResourceBundle variable _res which is used when creating our fields. To be able to use and explain them, we will first create our resource files.</p>
<h3><strong>Creating resource files</strong></h3>
<p>To be able to localize your application, you need to create .rrc and .rrh files. It is quite easy to create these files in Eclipse.  Click on File-&gt;New-&gt;BlackBerry Resource File and browse to the location of your package.  You will need to name your header file here &#8212; let’s call this file LocalDemo.rrh (make sure you include the extension). Pressing Finish on this screen will now allow you to implement LocalDemoResource interface.</p>
<p>If you called your .rrh file “exampleResource.rrh”, then the interface name would be exampleResource.  Now we need to create resource files for each language:</p>
<p>For default language: LocalDemo.rrc<br />
French: LocaLDemo_fr.rrc<br />
Spanish: LocalDemo_es.rrc.</p>
<p>The parts of the name _fr and _es are default endings for those languages and cannot be changed.<br />
If you did everything correctly, you should have 4 resource files just under your Local.java file.  Now we need to edit these files. Double click on the LocalDemo.rrh file &#8212; this is the one which contains all the keys.  Select the ‘Add Key’ Button and add the following fields:</p>
<p>CLOSE, ENGLISH, FIELD_TITLE, FRENCH, GOODBYE, MESSAGE, SPANISH.</p>
<p>You do not need to enter the values on this page.  When you double-click on the LocalDemo.rcc file, it will open the screen where you can fill in the values. You can access the values for French and Spanish locales by clicking on the tab on the bottom of the window (marked fr or es), or by double-clicking on the file name.</p>
<p>As you can see, special characters used in these languages such as ‘ó’ in word “adios” or ‘ñ’ in “Español” were used. The system will use those characters and display them when needed. You can use any Unicode characters here, which means you can support languages such as Chinese or Arabic.</p>
<p>And that’s it! That’s all you have to do add multiple language support to your BlackBerry application.  For more info and to see a full working demo, refer to this link:<br />
<a href="http://supportforums.blackberry.com/t5/Java-Development/Introduction-to-Resource-Bundles/ta-p/507362" target="_new">http://supportforums.blackberry.com/t5/Java-Development/Introduction-to-Resource-Bundles/ta-p/507362</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/9641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/9641/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9641&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/05/app-internationalization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/83a3304d7f99cd7e5d2323b7338f7305?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">naveenm1</media:title>
		</media:content>
	</item>
	</channel>
</rss>
