Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

OleDateTime in multiple languages

Posted on 2001-06-22
3
Medium Priority
?
289 Views
Last Modified: 2013-11-20
What's the best way to get the day of the week in a foreign language out of OleDateTime?

Ole.Format("%A") is nice if I want Wednesday but
how can I ask it to give me the German, Mittwoch, or French equivalent?
0
Comment
Question by:gkibble
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Expert Comment

by:GloriousRain
ID: 6220827
CString Format( DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT );
You should use lcid for Ole.Format,lcid indicates locale ID to use for the conversion. See below article for more info
<MSDN>
Supporting Multiple National Languages
Applications sometimes need to expose objects with names that differ across localized versions of the product. The names pose a problem for programming languages that need to access these objects, because late binding will be sensitive to the locale of the application. The IDispatch interface provides a range of solutions that vary in cost of implementation and quality of language support. All methods of the IDispatch interface that are potentially sensitive to language are passed a LCID, which identifies the local language context.

The following are some of the approaches a class implementation can take:

Accept any LCID and use the same member names in all locales. This is acceptable if the exposed interface will typically be accessed only by very advanced users. For example, the member names for OLE interfaces will never be localized.
Accept all LCIDs supported by all versions of the product. In this case, the implementation of GetIDsOfNames would need to interpret the passed array of names based on the given LCID. This is the most acceptable solution because it allows users to write code in their natural language and run the code on any localized version of the application.
Return an error (DISP_E_UNKNOWNLCID) from GetIDsOfNames if the caller's LCID does not match the localized version of the class. This prevents users from being able to write late-bound code that runs on machines with different localized implementations of the class.
Recognize the particular version's localized names, as well as one language that is recognized in all versions. For example, a French version might accept French and English names, where English is the language supported in all versions. Users who want to write code that runs in all countries would have to use English names.
To provide general language support, the application should check the LCID before interpreting member names. Because Invoke is passed a LCID, methods can properly interpret parameters whose meaning varies by locale. The following sections provide examples and guidelines for creating multilingual applications
<MSDN>

0
 

Author Comment

by:gkibble
ID: 6225217
I did read the section on CString.Format but it did a poor job of explaining
   Format( DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT );

There is a version of Format where one can pass "%A" to get day of the week and another where one can specify the LCID. It's not at all obvious how to do both at the same time.

Does calling the LCID version of Format permanently set the LCID for all future calls to Format?

-gary
0
 
LVL 2

Accepted Solution

by:
GloriousRain earned 400 total points
ID: 6226162
Use char *setlocale( int category, const char *locale );
Before Ole.Format("%A")
Ex: German
...
setlocale(LC_TIME, "German");
Ole.Format("%A")
...
you should search in MSDN "language strings" for more locale. Any language not supported by the operating system is not accepted by setlocale
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question