How can I read native text of current locale?
2009-11-22 21:54
369 查看
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 VerLanguageName 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}
VerLanguageName(ID, LanguageName, SizeOf(LanguageName));
ShowMessage(LanguageName);
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
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 VerLanguageName 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}
VerLanguageName(ID, LanguageName, SizeOf(LanguageName));
ShowMessage(LanguageName);
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
相关文章推荐
- HDOJ_ How can I read input data until the end of file ?
- Units Problem: How to read text size as custom attr from xml and set it to TextView in java code
- how to read source code of angular?
- SOS: Autodesk MapGuide Studio - Preview can not display "Feature Label" with Chinese text on the platform of MapGuide Open Source
- how can i read a key from App_GlobalResources files ?
- svn locale Can't convert string from native encoding to 'UTF-8'
- Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if
- How can I protect derived classes from breaking when I change the internal parts of the base class?
- RadTreeView: How to Wrapping the text of tree nodes
- HTML5 File API: How to see the result of readAsText()
- [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as r
- How can I put a checkbox in a column of my DataGrid?
- How to read the contents of a remote web page
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change the text color of the selected property sheet tab in Visual C++
- how can i get [5, 7, 13, 2] to go to [5*0, 7*1, 13*2, 2*3] then get the sum of this array.
- How to read very large text files fast
- How can I dump only certain entries of a table based on my condition?