Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Libraries and TheIDE: i18n, Unicode and Internationalization » GetLanguageCode
GetLanguageCode [message #19685] Mon, 05 January 2009 17:34 Go to previous message
White_Owl is currently offline  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?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how to add ISO10646 charset?
Next Topic: GetNativeLangName returns English for non-english languages
Goto Forum:
  


Current Time: Mon Apr 29 08:52:41 CEST 2024

Total time taken to generate the page: 0.02098 seconds