Home > Articles > Programming > Visual Basic

Like this article? We recommend

Like this article? We recommend

Language and Locale

Language is a term that just about everybody is familiar with; it is a grouping of sounds and symbols that are organized into combinations and patterns that enable people to communicate. A locale, on the other hand, is a specific international market where a target user is working. A locale encompasses many of the issues discussed earlier when I defined localization: the conventions, culture, language, and preferences of typical users in the environment. This includes issues that are crucial to applications, such as number, currency, date/time formats, and date/time separators.

Usually, when you are discussing issues in i18N, it makes more sense to refer to locales than to languages. The reason for this is twofold:

  • The language alone is usually not a good indicator for items defined in a locale. For example, in both America and Great Britain, the language spoken is English. However, in America the built-in short date format is mm/dd/yy, so January 4, 2000, would be represented as 01/04/00. In Great Britain, the dd/mm/yy format is preferred, which means that people there would expect the same date to be represented as 04/01/00. There is obviously a lot of room for confusion within an application if you display such information or your users type such information in the wrong format.

  • In many cases, a language is spoken in very different ways between two different regions. One example of this is the difference between Brazilian Portuguese and Iberian Portuguese (as spoken in Portugal). For example, the following phrase "data that is stored in a Microsoft Jet or Microsoft SQL Server database" might be translated to "dados queest[td]ao armazenados em uma base de dados do Microsoft Jet ou do Microsoft SQL Server" for Brazilian Portuguese, but into "esses dados s[td]ao armazenados numa base de dados do Microsoft Jet ou do Microsoft SQL Server" in Iberian Portuguese. It might look like a minor difference, but it's one that people who speak the language will notice.

Throughout the book, special care will be used to be very specific about referring to language and locale as appropriate.

Locale ID (LCID)

In an effort to define locales in ways that enable users to choose a single setting rather than having to individually set every preference, Microsoft has defined a large database of information that is intended to be specific to every covered language, country, and sort combination. Not every possible locale is covered; in fact, almost without exception, languages are supported with an LCID only if there is a country or at least a region that speaks the language. (Therefore, you will probably never see an LCID for Coptic or Latin, and you will certainly never see an LCID for Klingon, even though a Klingon extension to the Unicode standard has been proposed and has even been included in some Unix implementations!)

LCIDs are made up of four parts:

  • PRIMARYLANGID—A primary language ID, which defines the language

  • SUBLANGID—A sublanguage identifier, which defines the country or region

  • SORTID—A sort identifier, which defines the way that the language is sorted

  • SORTVERSION—A sort version, which is not currently used but is defined so that future versions of Windows can use alternate versions of a sort if this is ever required

The layout of the LCID in memory can be seen in Figure 10.

Figure 10 The layout in memory of a 32-bit LCID value. The currently used sort version uses a small part of the reserved area.

LCIDs will be used at many points throughout this book. C and C++ developers have been given many helpful macros to parse these numbers and obtain the relevant portions of them. Although these macros are not available in Visual Basic, I do provide wrapper functions that provide the same functionality (the main difference is that in C, the macros would be inserted into every instance in which they are used by a preprocesser, whereas in VB they are actual functions that will exist even in a compiled project).

The information represented by an LCID (usually pronounced el-sid) is used heavily by Visual Basic, by COM, and by the operating system itself, and its settings fundamentally affect the processing of information on the machine. LCIDs will be heavily discussed throughout the book. The specific parts of LCIDs are further discussed in the following sections.

Primary Language Identifier (PRIMARYLANGID)

As I mentioned, the primary language identifier represents the language itself. A good example is English, which is spoken in many countries but always has the same PRIMARYLANGID, LANG_ENGLISH. Some countries have multiple languages that are spoken; therefore, LANG_TAMIL and LANG_BENGALI both exist to represent two different languages spoken in India.

Sublanguage Identifier (SUBLANGID)

The SUBLANGID represents the country or region in which the language is spoken. This is obviously needed for cases such as French spoken in Belgium (represented by SUBLANG_FRENCH_BELGIAN) as compared to the French spoken in Canada (represented by SUBLANG_FRENCH_CANADIAN). The distinction between sublanguages is important just for word usage issues within a language, even before taking into account the other issues that make up a locale. This makes the SUBLANGID a very important component.

Language Identifier (LANGID)

The LANGID, or language identifier, is simply a combination of the PRIMARYLANGID and SUBLANGID. As the next section discussing the sort identifier indicates, in most cases, the LANGID and the LCID will be the same value because most languages do not have special sorts.

Sort Identifier (SORTID)

At first glance, PRIMARYLANGID and SUBLANGID seem to be able to cover everything, but, in the end, that proves to be a bad assumption. The differences in the way that Hungarian is sorted under normal circumstances versus in technical documentation, and the way that Georgian is sorted in the modern versus the traditional use of the language, are indeed important cultural factors that can be key to properly displaying information in an appropriate order. In most cases, SORT_DEFAULT (which is 0) is used, thus making the LANGID and the LCID identical.

Sort Version (SORTVERSION)

Recent versions of the Platform SDK have added macros to handle a sort version. It is currently unused and even the documentation in the SDK does not discuss what its intended future use might be. (It simply states that this parameter is reserved and must always be 0.) I would suspect that this part of the LCID is present so that future versions of sorts that are almost identical but have small variations can be represented in ways that will allow Windows to optimize sorting operations.

Because no sort versions are currently defined, they are not really discussed much in the rest of the book, although the macros that manipulate them have been converted to functions just as the other LCID macros have.

It is worth noting that there are specific times in which a SORTID or even a SORTVERSION would probably have been a good way to handle a specific language difference, but it was not used. The best example of this is the difference between the Traditional Sort Spanish LANGID (1034) and the Modern Sort Spanish LANGID (3082). There are no differences in any of the locale settings or characters in either language. The difference between the two is that the way particular characters are sorted has been changed. Specifically, in the traditional sort order, the letter combination ch is a unique compression in the sort between c and d; in the modern sort, it's considered as c followed by h. Similarly, in the traditional sort, the ll compression is a unique letter in the sort between l and m; in the modern sort, it is considered as l followed by l. This would have made Modern Sort Spanish an ideal candidate to be defined as LANGID 1034 with a new SORTID; unfortunately, this was not done, and Modern Spanish has its own LCID. So, instead of an LCID of 66570, Modern Spanish has an LCID of 3082. In fact, the reason that Modern Spanish (whose name, incidentally, was changed to Spanish [International] in Windows 2000) was not implemented with a new sort is that the SORTID component of LCIDs did not exist until more than a year later.

Worldwide EXE

The concept of the worldwide EXE is simple enough; it means that your application's code has one version for all languages. At first glance, the best way to handle other locales is to take the product that you have written and give it to a programmer from the other locale. For example, you would take your U.S. English program and give it to a Japanese developer, who could take care of changing the strings in VB forms, the code, and everything else to make sure that it is appropriate to the Japanese market. There are three major problems with this approach:

  • All the localized versions of the software will be available much later than the original version. Because you would be handing off your finished application, you have to wait until it is done or you risk having to fix bugs in multiple places.

  • It is much more expensive to have extra programmers do the work. As you add on languages, you are essentially paying for one programmer per language. This can become prohibitively expensive.

  • Your product is going to be either a very hard-to-maintain single version or multiple versions. It is hard to say whether it is worse to have to maintain multiple versions of a product or maintain a product with code such as this:

      Select Case g_language

      Case ENGLISH_VER

      ' English-specific code here

      Case JAPANESE_VER

      ' Japanese-specific code here

      Case GERMAN_VER

      ' German-specific code here

      End Select

However, this approach will be very difficult in terms of maintaining the product, fixing bugs, or shipping future versions.

The solution is to have a single binary that contains the code and to isolate materials that need to be localized in another form (such as a database or resource files).

The concept is referred to as worldwide EXE even though, in truth, the worldwide component of your product can easily be many files that are EXEs, DLLs, ActiveX controls, and other files. In all cases, the idea is to separate from your core program anything that will change from language to language and also design your core program to be able to handle any language.

In the real world of software development, it is often slightly more complicated. Such a product cycle, which has happened for Visual Basic itself (in this case of the Package and Deploy [P&D] Wizard), goes something like:

  1. The product ships its source version (U.S. English).

  2. The localized versions of the product are shipped at a later date. The worldwide EXE approach was taken, but the later ship date means that testing happened later and that some bugs were fixed after the original ship date.

  3. An "internationally friendly" version of the P&D Wizard designed to enable VB developers to ship their localized applications was released at a later date and made available on the Web (at http://msdn.microsoft.com/vbasic/downloads/ipdk.asp, which, incidentally, has non-English links as well; an excellent step for a feature that will attract global interest).

The important difference between this type of product cycle and the original one discussed is that these changes are now considered part of the core code. Any and all bug fixes made along the way appear in all subsequent versions. In essence, what the VB team did was further globalize its product. Many bugs found by local testers were considered core bugs as a part of the worldwide EXE.

Input Method Editor (IME)

Everyone knows what a keyboard is, and keyboards are very useful when you need to type in text for most languages. When you are dealing with the Asian languages (also known as the Chinese/Japanese/Korean, or CJK, languages), a simple keyboard will not do the trick because there is no keyboard that has thousands of keys on it.

To solve this problem, Microsoft uses IMEs (input method editors) to allow for the input of such alphabets. These editors (some of which can appear in the list of input locales, as in Figure 11, and which often look much like the Japanese IME 2000 in Figure 12) provide the ability to input grouping information that approximates a character and then lets you choose the right character as needed.

Figure 11 If you install a lot of keyboards on Windows 2000, you may notice that many of the Asian languages look different than they do in other locales; these different graphics represent different IMEs.

Figure 12 Selecting the Japanese IME 2000 on a Windows 2000 machine will give you an interface in which you can handle the large number of Japanese Hiragana, Katakana, and Kanji characters that you may want to enter.

The IME is run by the Input Method Manager (IMM) API and is usually a system component and thus not one you will have to worry about very much.

Where We Just Were…

I have now introduced the subjects that will be covered in depth for the rest of the book, and I have defined many of the terms that I will be using, in case you either did not know any of the terms or perhaps might be using different ones than I am using. This should help direct your further reading and make sure that you will find this book to be a useful tool in the journey to a Visual Basic application that enables you to take advantage of the global marketplace.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020