Home » U++ Library support » U++ Libraries and TheIDE: i18n, Unicode and Internationalization » GetLanguageCode
GetLanguageCode [message #19685] |
Mon, 05 January 2009 17:34 |
White_Owl
Messages: 27 Registered: January 2009 Location: New York
|
Promising Member |
|
|
I have several localized texts in src.tpp and would like to load them in run-time according to the current user language.
The easiest way I can think of, is to do it with a code like this:
PromptOK(String("MyProject/src/About$") + GetLanguageCode(GetCurrentLanguage()));
And a function GetLanguageCode() is a slightly modified LNGasText():
String GetLanguageCode(int d)
{
String result;
int c = (d >> 15) & 31;
if(c) {
result.Cat(c + 'a' - 1);
c = (d >> 10) & 31;
if(c) {
result.Cat(c + 'a' - 1);
c = (d >> 5) & 31;
if(c) {
result.Cat('-');
result.Cat(c + 'a' - 1);
c = d & 31;
if(c) result.Cat(c + 'a' - 1);
}
}
}
c = (d >> 20) & 255;
return result;
} The change is that it does not add charset name and returns lower-case language code, exactly as TPP editor set language codes for topics.
Am I inventing a wheel?
|
|
|
Goto Forum:
Current Time: Mon Apr 29 08:52:41 CEST 2024
Total time taken to generate the page: 0.02098 seconds
|