Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Sybase PowerBuilder - DataWindow.NET with Multi-Language Support
Overcoming Sybase's limitations

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.

DataWindow.NET has two integral parts. One of them is intended to work in WinForms, the other in WebForms. In this article we'll use WinForms; however, our solutions are suitable for WebForms too.

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
Microsoft Visual Studio has built-in support for both globalization and localization. Globalization means applying culture-based formatting to existing data. Localization means presenting previously saved information dependent on the culture selected. Culture is cultural information that specifies language and region.

All cultures in the .NET Framework are identified by special culture codes. For example,

  • en: Specifies the English language, no region,
  • en-CA: Specifies the English language, Canada.
The specific culture can be changed using the CultureInfo class. The following code example demonstrates how to set current culture to French-Canadian:

// Set new Current Culture
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");

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
label1.Text = (500).ToString("C");

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
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");

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
We'll consider two possible approaches to implementing multi-language support in DataWindow.NET. The first solution is to dynamically change all culture-specific properties for the DataWindow objects. These properties include, for example, text, size, position, and color. The second solution is to have a separate DataWindowObject for each culture at design time and switch the DataWindowObject in use at runtime.

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
Modify() and SetProperty() functions are powerful tools to change the DataWindow presentation. It's possible to change the DataWindow objects' text, color, size, and position. For example, if we want to change the text to French we can call:

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
try
{
    // Combined name for resource search
    name = DataWindowObject + "." + DWObject + "." + ObjectProperty;

    // Read resources from dwModify resource file
    value = dwModify.ResourceManager.GetString(name);
}
catch(SomeException e)
{
    value = "";
    errmsg = e.Message;
}

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
The DataWindow .NET engine searches for the DataWindowObject using the specified LibraryList property. The main idea is to have one library (pbl-file) for the default culture and one additional pbl-file for each supported alternate culture. This additional pbl-file can contain the culture code in its filename or it could be put in a subdirectory with that name. For example, we can create the folder pbl and subfolders named en-GB and fr-FR. In the pbl folder we'll put the default library file demo.pbl and put demo.en-GB.pbl in the en-GB subfolder. The culture-specific library should appear before the default library in the library list:

Dw.LibraryList = "pbl\\fr-FR\\demo.fr-FR.pbl;pbl\\demo.pbl;"

You can see the directory structure in the Figure 4.


About Mikhail Klygin
Mikhail Klygin is a senior developer and has been using PowerBuilder since version 5.0.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

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. DataWindow.NET has two integral parts. One of them is intended to work in WinForms, the other in WebForms. In this article we'll use WinForms; however, our solutions are suitable for WebForms too.

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. DataWindow.NET has two integral parts. One of them is intended to work in WinForms, the other in WebForms. In this article we'll use WinForms; however, our solutions are suitable for WebForms too.

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. DataWindow.NET has two integral parts. One of them is intended to work in WinForms, the other in WebForms. In this article we'll use WinForms; however, our solutions are suitable for WebForms too.


Your Feedback
SYS-CON Australia News Desk wrote: 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. DataWindow.NET has two integral parts. One of them is intended to work in WinForms, the other in WebForms. In this article we'll use WinForms; however, our solutions are suitable for WebForms too.
PBDJ News Desk wrote: 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. DataWindow.NET has two integral parts. One of them is intended to work in WinForms, the other in WebForms. In this article we'll use WinForms; however, our solutions are suitable for WebForms too.
PBDJ News Desk wrote: 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. DataWindow.NET has two integral parts. One of them is intended to work in WinForms, the other in WebForms. In this article we'll use WinForms; however, our solutions are suitable for WebForms too.
Enterprise Open Source Magazine Latest Stories . . .
With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference... We have technical and st...
AMD said late Tuesday that its chief sales officer Emilio Ghilardi had left the company and that CEO and president Rory Read is going to do his job while a replacement is sought. AMD didn’t say why Ghilardi left but it’s assumed Read wants his own people. Read is relatively new to th...
During the lifespan of M3 (Monitis Monitor Manager) there has always been something lacking – timers. M3 execution procedure was outlined in this previous article. The execution mentioned in the latter was a one-time-execution, whereas server monitoring requires periodic invocati...
Red Hat is putting its bought-in Gluster scale-out NAS storage technology, acquired in October, on the Amazon cloud. It’s styled Red Hat Virtual Storage Appliance for Amazon Web Services and other clouds are supposed to follow in short order.
A new episode of the screencast series is now available at the OpenNebula YouTube Channel. This screencast demonstrates the new easily-customizable self-service portal for cloud consumers. Its aim is to offer a simplified access to shared infrastructure for non-IT end users. The scree...
C12G Labs has just announced an update release of OpenNebulaPro, the enterprise edition of the OpenNebula Toolkit. OpenNebula 3.2, released two weeks ago, brings important benefits to cloud providers with a new easily-customizable self-service portal for cloud consumers, and builders w...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE