How can I read native text of current locale?

Source: Internet
Author: User

How can I read native text of current locale?
Sometimes in application we want to show a text with description of current used locale.
For example, "English", "Russian", "Ukrainian", "Chinese" etc

For this task you can use verbose agename function from Windows API:

VaR
ID: langid;
Languagename: array [0 .. 255] of char;
Begin
{Read current system locale}
ID: = getsystemdefaultlangid;

{Convert an ID into text}
Verrentagename (ID, languagename, sizeof (languagename ));

Showmessage (cmdagename );
End;

Of course, you can expand this code and to translate a locale as parameter

For example, if ID is $419, you'll receive a "Russian ". for $ 0a-the "Spanish (traditional sort)", for $ 0c0c-the "French (Canadian)", for $407-"German (standard)" etc

Important

If ID is incorrect, you'll receive an "language neutral" as result
Text in result will be translated in the current language. I mean that text will be not in English if you have localized version of MS windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.