Flylib.com

Books Software

 
 
 

Building Client/Server Applications Under VB .NET: An Example-Driven Approach - page 106


Summary

This chapter covered a lot. You saw how to consume a Web service from a Web application and how to hook that same application up to your original components . You examined how to handle client-side rules without code and received a little lesson on regular expressions. You gained some insight on what Web page developers must go through as opposed to what a Windows forms developer must go through. But mostly you have gained the insight that a well-coded data-centric component can save you a lot of headaches and that displaying business errors is pretty easy once you figure out how to report the errors to the user .

In addition, you learned how to store database credentials in the registry and how to retrieve those credentials in a secure manner. You examined a host of security issues that allow you to determine what possible security issues you might face on a particular project and how to get around some of them.

In the next chapter you will globalize and localize both your Windows forms application and your Web forms application so that you will have hands-on experience with how to modify an application to accommodate different languages.



Chapter 13: Globalizing and Localizing Your Application

Overview

Chapter 1, "Understanding Application Architecture: An Overview," mentioned that the business world is becoming global. Boundaries are being blurred every day, especially in the business world. More businesses are based in multiple countries now than any time in the past, and those businesses are putting out their messages to people all over the world via the Internet. This means that many programs may need to have built-in support for multiple languages.

This chapter introduces some of the ideas and best practices you will need to know to globalize applications. In addition, you will globalize the Employee Edit forms for both your Windows application and your Web application and go over some of the techniques used in globalization.

Note 

This chapter is not an in-depth chapter on globalization and localization. If you are interested in an excellent book on all of the different aspects of these techniques, refer to Internationalization and Localization Using Microsoft .NET by Nick Symmonds (Apress, 2002). This book goes into much greater detail and provides you with a wealth of information if you need it.

Globalization is the process of preparing an application to be localized. Localization is the process of taking an application and adding in the resources used to display the interface in a user 's native language. This chapter examines both aspects.

Note 

I am one of those language-inept people. To quote Bruce Willis in The Fifth Element , "I speak two languages, English and Bad English." Because of this slight limitation on my part, the translations may not be entirely accurate, but I have tried my best to give them justice .



Introducing Globalization

You need to perform a couple of steps to globalize an application (most of which you have not done up to this point):

  • Ensure there is enough space in labels to hold the maximum size strings.

  • Store all strings (and images) if they are to be localized, externally of the executable.

  • Store all data in the database using Unicode encoding.

  • Do not concatenate strings at runtime for display.

    Note 

    There is a much longer list of best practices in the MSDN help documentation under "Globalization, Best Practices" and "Localization, Best Practices."

These are the only areas covered in this chapter because each requires some technical insight. Most of the other globalization issues revolve around the do's and don'ts of different political systems, cultures, and so on. You do have one advantage using the .NET Framework: All controls that display text are Unicode enabled, so character sets are no longer an issue.

Note 

This chapter is about converting an application to a different language, Appendix A contains a small example of adding special characters (including foreign language characters ) in an application designed to support only one language.

So, let's examine each of the four requirements listed previously.

Ensure there is enough space in labels to hold the maximum size string : When you create labels to hold text that describes information in a textbox or listbox, you generally size the label just large enough to hold the text so you can have a nice, neat form. However, look at the following word in English, then in French and Spanish:

  • Birth Date (English)

  • Date de naissance (French)

  • La Fecha del nacimiento (Spanish)

As you can see, it will not do to size labels to their minimum size when writing an application that eventually needs to be localized.

Store all strings (and images) if they are to be localized, externally of the executable : When you place a label on a form, you should store the text of that label in a place other than the text property of that label. In this case, I am specifically talking about a satellite assembly that contains resources. A satellite assembly, by definition, is an assembly that contains only resources. There is no application code in a satellite assembly. You should insert all text that is displayed in labels (and images that have local significance, such as flags, leaders , maps, and so on) into these labels at runtime.

Store all data in the database using Unicode encoding : Ensure that all character fields are created using the Unicode version (noted in SQL Server as n plus the datatype; for example, varchar would be nvarchar ). This also covers the fact that monetary values should be stored in money fields and not decimal or float fields because these will not automatically be converted and formatted according to the region. You should also store dates in date columns, not as text columns formatted as dates.

Do not concatenate strings at runtime for display : This is a big no-no when dealing with foreign languages. Take the following example: [1]

  • English: Release the hold and start the second by one press on S1 at the appropriate time.

  • French translation: Publiez l'influence et commencez la seconde par une presse sur S1 au temps de l'appropriate.

  • English translation from French: Publish the influence and start the second by pressing S1 at the time of the appropriate.

So, if you were to create a string by inserting variables into the string at the same locations in English and French, the results would be incomprehensible to anyone in the foreign language.

You are going to create your own satellite assembly, read values from the assembly into your application dynamically, and resize labels where necessary. But before doing that, let's look at some of the tools available to you.

[1] This was inspired by an example of "bad translation" at http://www.fortunecity.com/business/ reception /19/mtex.htm .