|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top Links You Must Click On
DataWindows Sybase PowerBuilder - DataWindow.NET with Multi-Language Support
Overcoming Sybase's limitations
By: Mikhail Klygin
May. 24, 2006 10:15 AM
Microsoft Visual Studio has excellent multi-language support both at design time and runtime, while Sybase DataWindow.NET doesn't have that. In this article we'll consider how to implement multi-language data presentation using DataWindow.NET.
One of the most significant features of .NET technology is its ability to create applications for an international audience. The Microsoft .NET Framework has a rich set of classes set for globalization and localization. Microsoft Visual Studio WinForm Designer is tightly connected to the Resource Manager, allowing localized forms to be saved as resources. Unfortunately, the Sybase DataWindow.NET Designer can't save local information. There are two ways of providing different presentations based on a specific culture. One solution is to use the DataWindow control Modify() function and the other is to use different DataWindows for different cultures. Both solutions have their peculiar pros and cons.
Globalization and Localization in Visual Studio and DataWindow.NET All cultures in the .NET Framework are identified by special culture codes. For example,
// Set new Current Culture For globalization purposes, the .NET Framework supports formats for numbers, currencies, dates, and times for each culture. The following example sets the currency format:
// Set currency format For localization, Visual Studio saves a resource file for each form that contains the alternative form data for the given culture. The following code example demonstrates how to set a user interface current culture to French-France.
// Set new User Interface Current Culture Unfortunately the DataWindow.NET engine doesn't use the .NET Framework globalization and localization capabilities. For globalization purposes the DataWindow engine has several of its own special formats like "[currency]," "[general]," "[shortdate]," etc., but they're related to the local computer regional settings, not to the current culture. DataWindow.NET can't save localized data. The purpose of this article is to explain how to overcome this limitation.
Multi-Language Demo Let's create a simple application to demonstrate both approaches. In Figures 1-3 we can see a form with a combo-box to switch current culture, two buttons for the two different multi-language support methods, and a DataWindow where the results are shown. The figures show the form displayed for the English, French, and Russian cultures.
First Solution: Modify() Function dw.Modify("salary_t.text=\'Salaire:\'"); or dw.SetProperty("salary_t.text","Salaire"); Unfortunately, this approach has several limitations. First, there's no design-time support for creating localized information. Instead, we have to save all such information manually. Second, there's a layout problem. For example, English words are usually shorter than French or Russian. So we need to include extra spaces between DataWindow objects and increase their size. Third, it's not obvious where to save localized information. There are several places where the localized information could be saved. Among them are the database, registry, resources, and DataStore with saved data. The decision is up to the developer, but we recommend the database as the best solution because it's easier to maintain. Nevertheless, for purposes of this example we'll use localized resource files. We can add several resource files for each culture and put culture-specific information in them. For example, we put the data shown in Table 1 in the dwModify.fr-FR.resx file. The following code fragment reads resource information from the file:
// Try to read resources To simplify error handling we can create a Modify() style function. It's more familiar to PowerBuilder developers because it returns the error string (see Listing 1). Listing 2 contains a Modify() function that sets the resource-specific value for a given property.
Second Solution: DataWindow Replacing Dw.LibraryList = "pbl\\fr-FR\\demo.fr-FR.pbl;pbl\\demo.pbl;" You can see the directory structure in the Figure 4. Reader Feedback: Page 1 of 1
Your Feedback
Enterprise Open Source Magazine Latest Stories . . .
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||