viksoe.dk

EasyNLS


This article was submitted .


Application Features

  • Easy interface to Resource and Locale specific functions.
  • Lightweight COM object.

Description

I have been involved in the localization of several big projects now. It is always a struggle to revisit any application to make it language independent. Especially for Visual Basic 6 applications, which often lacks any previous preparation for this task.

The EasyNLS component implements a few needed objects and functions, which allows Visual Basic programmers to easily master the hassles of National Language Support (NLS).

The following 3 items are covered by EasyNLS:

The Locale object wraps the Locale specific functions in Windows.
A locale is a collection of language-related user preference information. Windows has at least one installed locale, but often has many locales from which the user can choose.
Using the Locale functions, you can query the System language, currency symbol, number and calendar formats and a range of country specific system information.

Localized applications use a binary resource DLL to store the application's text strings. The EasyNLS's Resource object wraps locating, loading, initialising and resource retrieval from separate resource DLLs.
Each binary resource DLL contains all the strings, images, and icons the application uses for one specific language. To add support for a new language, a new binary resource DLL can be added to the installation without changing any code.

To overcome a design problem in most of Microsoft's development tools, the global GetSystemFont function is supplied.
A Visual Basic Form uses a hard-coded font. Unfortunately the default fonts (MS Sans Serif, Tahoma, etc) doesn't display Chinese and Japanese glyphs. If you need support for these countries, you'll need to change the Form font and the font used by all the controls.
The GetSystemFont function can query the system for the default font, for the font used by the menu or in the standard message box. It also contains several fixes for Windows NT 3.51.

Localization

Localization means several different things:
  • Making sure all internal data structures will work with any language.
  • Making the application work with National Language specific settings (such as thousand separators, different currencies).
  • Making sure that all visual representation can be translated into a language specific resource. When presenting any text (in a dialog or message box) the text needs to be loaded from a resource, rather than presenting a hard-coded text string.
If your application fulfils these 3 goals, you are on your way to have a fully localized product.

Goal 1

The first goal basically means you need to make your application use UNICODE characters to internally represent strings and characters. This is not a big deal if you have strictly Visual Basic code. For C++ projects, this may however be a daunting task.
The EasyNLS component will not help you much in accomplishing this task. Visual Basic is already UNICODE all the way, so VB applications will usually not need changes.

Goal 2

The second goal of making your application work with regional settings can be tricky to achieve. It usually means meticulous code inspection and probably rewrite of some of the application's conversion and data handling routines.
Visual Basic programmers don't usually have access to a lot of information about the regional settings. The information must be extracted from Windows API functions, which are not easily accessible for most VB users.
The EasyNLS's Locale object gives the VB users full access to all the information needed about the current and any installed Locale.

Goal 3

The language translation itself is not something the programmer has to ponder about. But making the application ready for displaying text in different languages is a very crucial localization task for many products and a very painstaking one.
Microsoft Visual Basic 6 has support for resource DLLs. This is a great step in the right direction for support of what C++ programmers have used since the early Windows versions. However, if you need to manage several languages for a large project, you will find VB support for resources inadequate.
The EasyNLS's Resource object is a simple wrapper, but certainly very powerful one.
Put all the application's text strings into a separate DLL. Let the object locate the right language DLL and display the intended strings.

Source Code Dependencies

Microsoft Visual C++ 6.0
Microsoft ATL Library

Installation Guide

  • Copy the DLL to a directory of your choice and register it using the REGSVR32 utility.

See Also

EasyReg Component
EasyINI Component

Download Files

DownloadBinary Files and Documentation (16 Kb)
Source Code (49 Kb)

To the top