Globalization and Localization

Ms. Asha Bora has done some studies on Globalization and Localization.. Lets see what she has to say..

Globalization and localization are very important features of .Net framework, which is very useful and about which every programmer should be aware of while creating an application. If I want my application to be used by everyone then I have to make my interface in a language which everyone can understand or say in a global language. But at the same time it is not possible that everyone in the world knows a particular language. So, in order to make those people use the application, I have to publish it in their regional language or say in their local language, this is known as localization .

From the introduction of the article you must have understood the basic meaning of globalization and localization. Now let’s see a proper definition of it in terms of a programmer.

This very important feature is used by .Net to make our programs universal. Now if we talk in term of programming then GLOBALIZATION can be defined as the process of designing and developing an application that function for multiple cultures and regions, irrespective of the language and regional differences and LOCALIZATION is the process of customizing your application for a given culture and locale. It consists primarily of translating the user Interface according to a culture. Culture will decide date display settings (like, mm/dd/yyyy or dd/mm/yyyy), currency display formats etc.

Now, the process by which we can make sure that our program will be localized is known as Internationalization or Globalization. In simpler terms, Globalization can be defined as the set of activities which will ensure that our program will run in regions with different languages and cultures.

Thus, globalization is related to intrinsic (basic) code changes to support such changes we use Resource files etc. Whereas, localization is the process of using a particular culture and regional info so that the program uses the local languages and culture. This means translating strings into a particular local language. This covers putting language specific strings in the resource files. Globalization starts in the main construction phase along with the code development. Localization generally comes later.

Now let’s see how we define the culture and region code.

We all know that languages depend upon the geographical location. For example, French is spoken in France as well as in Canada (besides many other countries). But linguistically speaking, Canadian French is quite different from French spoken in France. Similarly, there are linguistic differences between US English and British English. Therefore, the language needs to be associated with the particular region where it is spoken, and this is done by using locale (language + location).

For example
: fr is the code for French language. fr-FR means French language in France. So, fr specifies only the language and FR specifies the region France whereas fr-FR is the locale. Similarly, fr-CA defines another locale implying French language and culture in Canada. If we use only fr, it implies a neutral culture (i.e., location neutral).

Now, in order to change the current culture, we have to change two properties of the CultureInfo class- UICulture and Culture.

ASP.NET can set the UICulture and Culture properties for the page to the language and culture values that are passed by the browser. Alternatively, you can set the UICulture and Culture properties explicitly, either declaratively or in code. You can also set the values declaratively in
Web.config file under the property and these two properties can be set using the overloaded constructor of the class and then we can use this class to change the culture of the currently executing program.

UICulture: gets/sets the user interface culture for the currently executing thread. This property helps the runtime to load the resource strings from a specific resource. This property can take neutral cultures as well as locales.
  • Thread.CurrentThread.CurrentUICulture = new CultureInfo(“fr”); OR
  • Thread.CurrentThread.CurrentUICulture = new CultureInfo(“fr-CA”);
Culture: gets/sets the region specific culture and formats of currency, dates etc. This needs language as well as location.
  • Thread.CurrentThread.CurrentCulture = new CultureInfo(“fr-CA”); // we have given locale
  • Thread.CurrentThread.CurrentCulture = new CultureInfo(“fr”); // wrong, will not work
In my next article I will talk about “How to implement Globalization in our application”.

References:

  • http://msdn.microsoft.com/en-us/library/ms227427.aspx
  • http://www.codeproject.com/Kb/aspnet/localizationByVivekTakur.aspx

<Pre> Tag in HTML

There are many times when you need to show some sample C#, or java or any other code in your web page. For proper understanding and readability, these kind of code snippets need proper formatting.

But..by default, browsers collapse all the spacings, tabs and line breaks.

So, for properly formatting such stuffs, what do you do ??

One way is to go through all the lines, and at every occurance.. manually replace the white spaces with , line breaks with <br/> tags. While writing loops, for every ‘ < ’ and ‘ > ’ signs write &lt; and &gt;, etc etc.

Don’t you think all this is a real pain ??

A simple solution to this problem is using HTML pre tag.

Pre tag simply displays the enclosed pre-formatted text. This means that it directs the web browser to render the section of text contained within pre tag, exactly as it is..including the line breaks and white spaces. The <pre> tag is supported in all major browsers.

When you place any paragraph with preformatted text such as some poetry or some lines of code.. directly inside the Body tag of HTML, browser ignores the spacing, tabs and line breaks used in its text formatting. This is because a web browser interprets your html document as being one long line. Sure, you may have tabs and line breaks in notepad aligning your content so it is easier to read for you.. but your browser ignores those tabs and line breaks. So, if you will enclose that preformatted text with HTML pre tag <pre> it will not ruin the formatting of the text and will display with its formatting preserved.

pre tag is a container tag, which means it begins with an opening <pre> element and ends with closing </pre> element. The common attributes such as id, style, class, title etc and the events such as onclick, onmouseover, ondbclick etc as common to most html elements..are applicable to pre tag as well.

This element can be contained inside other elements such as html "applet", "blockquote", "body", "button", "center", "del", "dd", "div", "fieldset", "form", "iframe", "ins", "li", "map", "noframes", "noscript", "object", "td", and "th", etc.

And it may contain any other inline elements except "img", "object", "applet", "big", "small", "sub", sup". "font", and "basefont".

The PRE element is handy for showing program code or part of file content as in the example below:

<pre>
function sayHello(){

int i =0;

for(i=0; i <=10; i++){
System.out.println("Hello World !!");
}
</pre>

You will see the output in your web page as :
function sayHello(){

int i =0;

for(i=0; i <=10; i++){
System.out.println("Hello World !!");
}
NOTE : By default, Pre tag displays the pre-formatted text in Courier font type.

A very good example for using pre tag is posting articles using blogger interface. Formatting the articles using blogger UI was a pain for me.. Pre tag really saved my life..


References :
•   http://htmlhelp.com/reference/html40/block/pre.html
• http://www.codetoad.com/html/text/pre_tag.asp

• http://www.htmlquick.com/reference/tags/pre.html

http://programming.top54u.com/post/HTML-Pre-Tag-for-Preformatted-
Text.aspx





RSS Feeds

RSS the most familiar abbreviation used by almost all bloggers, webmasters, News Providers and readers. This article presents our readers a breif introduction about Rich Site Summary or Really Simple Syndication  (RSS)

*Syndicationpublish or broadcast simultaneously in a number of media (taken from www.askoxford.com)

RSS is a format for syndicating news and the content of news-like sites, including major news sites like news.google.com, technology blogs like www.labnol.org  and personal weblogs. 
But it's not just for news. Pretty much anything that can be broken down into discrete items can be syndicated via RSS: the "recent changes" page of a wiki, the profile updates of your friends on Orkut, newly posted articles on blogs(e.g. www.blog.TechYoddha.com) and even the revision history of a book.


Why Should one have feeds?
  • It increases traffic to your site.
  • It builds brand awareness for your site.
  • It can help with search engine rankings.
  • It helps cement relationships within a community of sites.
  • It improves the site/user relationship.
  • With additional technologies, it allows others to give additional features to your serviceupdate-notification via instant messaging, for example.
  • It makes the Internet an altogether richer place, pushing semantic technology along and encouraging reuse. Good things happen when you share your data.
  • It gives you a good excuse to play with some cool stuff. {like i did by having a personal channel of feeds :-) }
  • By reducing the amount of screen-scraping of your site, it saves wasted bandwidth.


Creation of RSS:
It is just an XML file that you should have for creating an RSS feed.
Else everything is the beauty of the Feed Reader that you have viz. on Mobile, in Browsers, desktop application to read RSS feeds etc.


Steps:
  1. Create a valid XML file with .xml extension
  2. host it at some server e.g.  your public_html directory of your domain website
  3. access the file with a Feed Reader ( e.g. www.TechYoddha.com/ty.xml)
There are other 100s of RSS providers available to create your RSS feeds automatically for your blog posts (e.g FeedBurner, FeedBlitz etc.)


Contents of XML file:
  1. xml tag
  2. rss tag
  3. channel tag
  4. title tag
  5. link tag
  6. description tag
  7. item tag
  8. title tag
  9. link tag
  10. description tag


Sample Feeds:
  1. http://www.ndtv.com/convergence/ndtv/rssnat.asp
  2. http://www.hindu.com/rss/nushdline.xml
  3. http://feeds2.feedburner.com/TechYoddha


References: