Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
6 Months Free & No Setup Fees ASP.NET Hosting!
Search :       Advanced Search »
Home » COBOL .NET » Localization in COBOL .NET

Localization in COBOL .NET

This article will show you how to use the power of LOCALIZATION within Visual Studio .NET to create one screen and have it display different languages.

Author Rank :
Page Views : 3286
Downloads : 13
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
LocalizeCBL.zip
 
 
Nevron Gauge for SharePoint
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Overview

Do you create applications for use in multiple locations and languages? This article will show you how to use the power of LOCALIZATION within Visual Studio .NET to create one screen and have it display different languages. The source code was created with Microsoft Visual Studio.NET 2003 and Fujitsu NetCOBOL for .NET V2.0.

Background

With many companies being multi-national, developers are having to create applications not only in their native language, but also in languages for the countries in which their company has offices. And many times these additional languages present unique challenges due to the presence of local variants to the base language. In the past developers created the application in their language and copied the application to a new name and changed the presentation to the language where the application was going to be deployed. This resulted in having the same program exist for different languages, same core logic, but different presentation layer.

Through the use LOCALIZATION in Visual Studio.NET you can now create one code-base and have multiple presentation layers in different languages use the same code-base. Our example will use a simple WinForm that will enable you to view a screen in either English or German. Please remember though, the intent of the article is to show you how to enable multiple languages, and not present you with a completed application.

Our application has two screens. An Introductory screen:

and a presentation screen:

It is the presentation screen that we will enhance to display in German. We will not go into the specifics how to create a WinForm application using NetCOBOL for .NET. Please refer to the online documentation for assistance.

Multi-Language Capabilities

Microsoft has enabled multi-language capabilities within Visual Studio.NET via a combination of the LOCALIZABLE and LANGUAGE settings for the Form you are working on. By default your language setting is set to the the local area where you are. By changing these variables you can create language targeted screens.

Within Visual Studio.NET 2003 there are two ways to create a foreign language representation of your screens. One way is to use the utility "WINRES" and the other is to use the Designer. I chose to use the Designer so I can visually see what the changes will be to my screen and if any additional enhancements to the form will be required by changing the text being displayed. You begin by selecting your Form and reviewing the properties, looking under the Misc area for the LOCALIZABLE and LANGUAGE settings as such:

Notice the LANGUAGE and LOCALIZABLE settings are set to English(United States) and True respectively.  I want to create a form in German though so we need to change the LANGUAGE to Germany (Germany) by using the drop-down list. Notice the different versions of German available to you? You can target the specific dialect of a language by first reviewing the options available to you and then selecting the closest version of that language.

For further information on what language settings are available see the CultureInfo Class in the .NET Framework help.

 When you select a new language you will notice the creation of several new files in the Solution Explorer. These files are XML based project files that will contain the language specific items for the screen.  The following image shows the files:

The red box is highlighting the two new files that were created when we selected the German language from the drop-down list in the form properties. If you were to look at these files in VS.NET you will see they appear as spreadsheets with the name, value and other pieces of information necessary for VS.NET to display the new values. Take a moment and review the files in the solution provided. You will see the values for the labels already present.

What VS.NET did was create a copy of the original screen, with all the objects on it, and provide you with a formatted way in which to change the language to German. You have the original screen to use as a guide so you know what it is you are changing and where, instead of trying to change something in a spreadsheet styled display. Using the Designer to create the foreign language version of your screen enables you to see what it looks like as you are changing it. This permits you to see right away if changes to the text will require the size of the labels to change, which you can do right away since you are already in the Designer!

Select the Form and change the LANGUAGE back to English(United States). Notice the Designer does not load a new form, but merely updates the existing form with the new language settings from the RESX file for English(United States).

The Driver Program

Since I do not want to change the code page my computer is using I created the driver program to demonstrate the use of the multi-language capabilities. The driver program, FORM1.COB, has two methods (one for each click event of the command buttons) that set a variable, create a new Globalization instantiation and finally show the form using the new Globalization instance. Since both methods are relatively the same I will show the German method:

CLASS-DEMO was established in the REPOSITORY as a reference to the DEMO form. We instantiate the form, passing it a flag telling it which language we want to use and then show the form. The real secret is in the "NEW"  method of the DEMO class.

Enablement

An overloaded "NEW" method was created in the DEMO program.

The original "NEW" method is shown for comparison. Two variables were added, an object reference to the CULTUREINFO class (objGlobalization) and a LINKAGE parameter to accept the value being passed from the driver program (LNK-LANG-IND).

The language indicator being passed in is evaluated. The values used for the instantiation of the CultureInfo class were determined from the documentation and from the value created for the RESX files. The properties for the CURRENTCULTURE and CURRENTUICULTURE must be set to the new culture info we established prior to invoking the InitializeComponent method. When the form is displayed, depending on which language was selected will determine which form is displayed. Windows will now display the proper information for the correct language.

Wrap-Up

That's it. Once you see how it is done the process is so simple, yet very, very efficient and effective! Unzip the source file, rebuild the solution and execute the process without debugging the first time so you see what is displayed. Next step into the code and visually see what is occurring. Finally, and this should put everything into perspective for you, select the English language in the LANGUAGE property, then select a new language, say Italian. Notice the files that are created and then modify the screen in the Designer to say 'Italian' instead of 'German'. Then add a button to the driver program to call your new Italian screen. Finally update the overloaded "NEW" method to create an Italian instantiation of the CultureInfo class, recompile the solution and see what happens.

Maintenance Note: Once you have created the new screens you can provide a translator or someone familiar with the local language, the spreadsheet representation of your screen and they can 'tweak and tune' the language to be more accurate. You can maintain the specific language items in either the spreadsheet format or the Designer.

I hope you find this article interesting and useful! Happy Coding!

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Rick Malek
Rick Malek is a Systems Engineer with Fujitsu Software based in Minot, North Dakota. While his primary duties are pre-sales support, Rick also does Consulting and Training. He has worked with COBOL since 1984, originally working on an IBM mainframe with CICS, VSAM and DB2.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments
6 Months Free & No Setup Fees ASP.NET Hosting!
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.