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:

Jagged Arrays

Our dear friend Ms.Asha Bora has done some studies on the wonderful Jagged Arrays..
Lets see what she has to say..

In this Article I will be discussing about Jagged Arrays. Many of us who are working as a Programmer may not be knowing about it, as I didn't knew it. One of my friends told me about Jagged Arrays. So I thought that I should explore myself on this topic so that people like me can know more about it..

.Net supports two types of Arrays:
Single dimensional arrays(Linear)
Multi-dimensional arrays - These are of two type : Rectangular Arrays and Jagged Arrays

What are Jagged Arrays?

A jagged Array is nothing but a multidimensional array, whose elements are arrays. The elements of an array can be of different dimensions and sizes. A jagged array is also known as “array of arrays”. Following is an example to show the declaration and initialization of jagged array:

i. Declaration : int[][] jaggedArray = new int[3][];
       Over here‘3’shows the number of rows in the array.

ii. Initialization: There are many ways to initialize a jagged array. In the given example each of the element is a single dimensional array.

jaggedArray[0] = new int[5];
jaggedArray[1] = new int[4];
jaggedArray[2] = new int[3];


We can also do initialization of the arrays without knowing its size.
For Example :

int[][] jaggedArray2 = new int[][]
{
   new int[] {1,3,5,7,9},
   new int[] {0,2,4,6},
   new int[] {11,22,33}
}
;

We can also do this in the below given way. Notice that we cannot omit the new operator from the elements initialization because there is no default initialization for the elements..

int[][] jaggedArray3 =
{
   new int[] {1,3,5,7,9},
   new int[] {0,2,4,6},
   new int[] {11,22,33}
};

NOTE: A jagged array is an array of arrays, and therefore its elements are reference types and are initialized to null. The length property of the array returns the number of arrays contained in the jagged array.

The following C# example will tell us how we can iterate in a jagged array.

class JaggedArray_Test
{
static void Main()
{
// Declare the array of two elements:
int[][] jaggedarr = new int[2][];

// Initialize the elements:
jaggedarr [0] = new int[5] { 3, 9, 15, 21, 27 };
jaggedarr [1] = new int[4] { 6, 12, 18, 24 };

// Display the array elements:
for (int i = 0; i < jaggedarr.Length; i++)
{
System.Console.Write("Element({0}): ", i);

for (int j = 0; j < jaggedarr [i].Length; j++)
{
System.Console.Write("{0}", jaggedarr [i][j]);
System.Console.Write(“ ”);
}
System.Console.WriteLine();
}
}
}
OUTPUT will be: Element(0) 3 9 15 21 27
Element(1) 6 12 18 24

Difference between multidimensional arrays (also known as rectangular arrays) and jagged arrays:

In a multi-dimensional array we have to declare both dimensions. Suppose we want to store the number of months and the days of each month in an array. If we create a multidimensional array then we have to give a fixed size to both the number of rows and column (To store the number of days for the month).But since each month has different number of days thus declaring the fixed size will lead to wastage of memory. Thus in this case we can use jagged arrays, as we don’t need to declare the second dimension of the array. It is enough to declare just the number of rows (to store number of months) in jagged array. The column or say the size of each linear array will vary as per the requirement.

THUS WE CAN SAY Jagged arrays have certain advantages over rectangular arrays. Jagged arrays are more space efficient, since not all rows (in a two-dimensional array) must have the same number of columns. In addition, since each row has its own one-dimensional array, we can easily pass an individual row to a method that requires a one-dimensional array parameter.
We will find working with jagged arrays much easier if you keep in mind that a jagged array is really an array of arrays.

References :
 http://msdn.microsoft.com/en-us/library/2s05feca(VS.80).aspx
 http://www.odetocode.com/Articles/253.aspx
 http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=128


LINQ : An Introduction

In this article, we will be discussing a very useful Microsoft technology called LINQ..which was introduced with .Net 3.0.

So, Lets see what LINQ is..

LINQ stands for Language Integrated Query. It is Microsoft’s new technology for powerful and easy general purpose data access in a type-safe way.

Now the question arises : What was the need to develop LINQ ??

Well.. the problem was that.. Traditionally, our data source used to determine our selection of a low-level data access API. For example, to fetch relational data from a database table, we would use ADO.NET, to parse XML data, we might use some combination of XPath and XML DOM APIs. Each data access API requires its own specialized syntax (SQL queries, as an example), and typically forces us..the developers to shuffle data between their business objects and the data access API.

All of the diverse data access strategies and APIs means there is a tremendous amount of mental energy expended to build the basic data features needed in every business application. LINQ helps us to eliminate this mental overhead.

Basically, It defines a set of standard query operators in the System.Linq namespace to select, filter, aggregate, and partition data from any type that implements the IEnumerable or IEnumerable <T> interfaces. The standard query operators are compliant with the Common Language Specification (CLS) and work inside any .NET language that supports generics. LINQ gives .Net developers the ability to query and transform data using any .Net Language of their choice.

LINQ is very similar to SQL. So, if you are used to using SQL to query databases, you are going to have something of a head start with LINQ.

This means that whether the data lives in XML, or database, or some collection of objects, we can run through the desired data in a common way..by simply writing SQL like queries.. Query expressions, like “from”, “where”, and “select”, “order by” and all the others you know and love from SQL can now be used in C# and VB .Net.

Lets now jump on to our first code and see how does LINQ code looks like..

In the following C# code, we are using LINQ to query a collection of Strings.

string[] flowers = { "Rose", "Lotus", "Jasmine", "Lily" };
IEnumerable query = from n in flowers
           where n.Length == 4
           orderby n descending
           select n;
foreach (string flower in query)
{
   Console.WriteLine(flower);
}

Inside this code is a LINQ query expression. The code will print out all the flower names in descending alphabetical order. We will discuss on the LINQ syntax in our future article.

The next query produces the same results, but queries data inside an XML fragment.

XElement flowers = XElement.Parse(
        @"<flowers>
           <flowers>Rose</flowers>
           <flowers>Lotus</flowers>
           <flowers>Jasmine</flowers>
          <flowers>Lily</flowers>
         </flowers>"
        );


IEnumerable query = from n in flowers.Elements("flowers")
          where n.Value.Length == 4
          orderby n.Value descending
          select n.Value;
foreach (string flower in query)
{
   Console.WriteLine(flower);
}

Although we made some slight changes to dig into the XML, the operators inside the query expression remains the same. LINQ query expressions are similar to SQL SELECT commands with FROM, WHERE, ORDERBY, GROUP, AND SELECT clauses.

Microsoft also designed LINQ to integrate closely with .NET languages and their environment. When typing the above queries, Visual Studio provides Intellisense for auto-completion. The compiler can perform syntax and type checking on query expressions.

Thus, we discussed the use of LINQ and what LINQ is.. We also saw an example of implementation of LINQ. We will be carrying on with the LINQ in our coming articles..

References :

http://msdn.microsoft.com/
• http://www.odetocode.com/
• http://www.programmersheaven.com/
• http://blogs.msdn.com/cyrusn/



FAQs on SSL Security

Ms. Asha Bora is now answering the frequently asked questions on SSL Security..

01. What is Secure Sockets Layer (SSL)?
Ans. SSL is an abbreviation used for Secure Socket Layer. It protects the data transfer over the http using the cryptography technique by using a server’s SSL certificate.

02. What is cryptography?
Ans. It is an art of protecting information by encrypting it or says by transforming it into a format which we cannot understand. Only those who possess a secret key can decrypt the message into a readable format. Cryptography is used to protect e-mail messages, credit card information and corporate date.

03. Can I try an SSL Certificate before purchasing?
Ans. You can test SSL in a pre-production server environment with a trial SSL Certificate free for 14 days. SGC-enabled and Extended Validation SSL Certificates are not available in a trial version.

04. What encryption strength do I need for my Web site?
Ans. Best security practices are to install a unique certificate on each server and choose a True 128-bit Certificate by purchasing a Server Gated Cryptography (SGC)-enabled SSL Certificate. A unique certificate keeps your private keys protected, and an SGC-enabled certificate ensures that every site visitor, no matter what browser or operating system they use, connects at the highest level of encryption their system is capable of. You need 128-bit or better encryption if you process payments, share confidential data, or collect personally identifiable information such as social security or tax ID number, mailing address, or date of birth. You need 128-bit or better encryption if your customers are concerned about the privacy of the data they send to you.

05. What do we mean by High Assurance Certificates?
Ans. High Assurance Certificates are fully authenticated certificates that produce confidence and trust. They have a 4 step authentication and verification process that verifies the domain name and company legitimacy. A visitor is fully satisfied that his information or transaction is fully secured if a website has a HA Cert. These are used by e-commerce websites with high value transactions and where there is sharing of confidential data. Information such as the Domain ownership, Company name, Address, Expiry date of the Certificate and Details of the CA are included within the certificate.

SSL Genie's Premium Certificates, VeriSign® SSL Certificates etc. are high assurance certificates for high risk high value transaction segment.

06. I want to buy the most basic entry level certificate. Which Certificate should I buy?
Ans. Flash SSLGenie Domain Validated certificates, VeriSign® Secure Site certificate etc. are the entry level certificates that provide medium level security. It is a one step verification and authentication process that verifies only the domain name. The domain is validated using an automated system they are used by websites which have a transfer of low value transactions and information which is not highly confidential.

07. What is the benefit of buying a site seal?
Ans. The site seal allows your customers to identify and confirm that your web site is using a leading SSL certificate. The seal resides on your web pages, identifying your site as genuine, authentic and validated by an independent third- party. The various advantages of having the site seal on your website are :

• By clicking on the SSL Trusted Site Seal visitors will get real-time confirmation of the validity of the certificate on the web server that they are connected to.
• It is a secure image with a direct link to the certificate server for verification.
• Tells customers that they can trust their online transactions conducted with you.
• Can be displayed on multiple secure pages.
• Is simple to install.
• Contains a date stamp reflecting your customer's time zone, providing real-time assurance of the authenticity of your site.

08. What is an SSL VPN?
Ans. An SSL VPN (Secure Sockets Layer Virtual Private Network) is a form of VPN that can be used with a standard Web browser. In contrast to the traditional IPsec (Internet Protocol Security) VPN, an SSL VPN does not require the installation of specialized client software on end users' computers.

The SSL VPN can be a good choice for schools, libraries and public kiosks where trust can be an issue but easy access is also important. Applications include Web-based e-mail, business and government directories, databases for educational institutions, file sharing, remote backup, remote system management and consumer-level e-commerce.

SSL Genie Certificates are specifically suited for this purpose.

09. How can I come to know if the website I am on is SSL safe?
Ans. When a user enters a site that is SSL enabled, he will see a "pad lock" at the browser's status bar indicating that the page is protected by SSL. When a site is SSL enabled, it means that the data transmitted between the browser and the site is encrypted. For example, Web image's signup page is SSL enabled.


When a website has an SSL Certificate integrated, its address normally starts with https:// instead of the regular http://. The addition of "s" indicates that the connection to the website's server is now secure and private data that is entered into the website can't be read by anyone except those authorized to read it.

10. What is the difference between SSL and s-http?
Ans. Apart from SSL, another protocol for transmitting data securely over the World Wide Web is Secure HTTP (S-HTTP). Whereas SSL creates a secure connection between a client and a server, over which any amount of data can be sent securely, S-HTTP is designed to transmit individual messages securely. SSL and S-HTTP, therefore, can be seen as complementary rather than competing technologies. Both protocols have been approved by the Internet Engineering Task Force (IETF) as a standard.

References :

• http://www.livehelpgenie.com/
• www.verisign.com/ssl/ssl-information-center/how-ssl-security-works