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 » How to display several languages without translation files?
How to display several languages without translation files? [message #4417] Sat, 05 August 2006 18:36 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
this topic is a continuation of:
http://www.arilect.com/upp/forum/index.php?t=msg&th=270& amp;start=0&
My question is:
How to display several languages without translation files (data coming from a database)?
(I have to have at least 3 languages)
1 case:
several languages in one string to one text (or array) controls?
2 case:
several languages from different differently encoded strings each going to a separate text (or array cell) control.

For the 1 case, AFAIK, the only possibillity is unicode/utf or WString. Am I right?
While I have succeeded this way for ArrayCtrl, I can't get the same for Label text. I guess this is not possible without telling it when to switch different language encodings (code pages) inside the text. Am I right?
That why I am asking for case 2.
Then I would like to write:
Label l;
WString ru_ru1=ToUnicode("Революция",255); //in fact it comes from DB
l.text=RU_RU(ru_ru1);
...

and accordingly for all other languages.
Then,
SetLanguage(LNGC_('R', 'U', 'R', 'U', CHARSET_WIN1251));
is no help? Am I right? (BTW, What is the scope of SetLanguage? global project, file, or several lines until next one?)

I tried different:
//	rus2=ToCharset(CHARSET_WIN1251, rus2, 255);
//	rus2=ToCharset( CHARSET_KOI8_R, rus2,CHARSET_WIN1251);
	rus2=ToCharset( CHARSET_KOI8_R, rus2,255);


but with no succes.
What is the correct way?
Re: How to display several languages without translation files? [message #4418 is a reply to message #4417] Sat, 05 August 2006 21:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12735
Registered: November 2005
Ultimate Member
What is DB encoding?

Mirek
Re: How to display several languages without translation files? [message #4421 is a reply to message #4418] Sun, 06 August 2006 00:10 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
luzr wrote on Sat, 05 August 2006 20:07

What is DB encoding?

Mirek


Forget DB.

The problem is to make several labels with a different language each. Or column titles. From *.cpp file. Is this possible? If yes, how?

Edit: P.S -no translation files. Not using translation files.

Edit2:

like this
...
Label l;
WString ru_ru1=ToUnicode("Революция",255);
l.text=???(???,ru_ru1,???);
...

I've set the existing *.cpp file to UTF8.

[Updated on: Sun, 06 August 2006 01:58]

Report message to a moderator

Re: How to display several languages without translation files? [message #4422 is a reply to message #4421] Sun, 06 August 2006 08:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12735
Registered: November 2005
Ultimate Member
fudadmin wrote on Sat, 05 August 2006 18:10

luzr wrote on Sat, 05 August 2006 20:07

What is DB encoding?

Mirek


Forget DB.

The problem is to make several labels with a different language each. Or column titles. From *.cpp file. Is this possible? If yes, how?

Edit: P.S -no translation files. Not using translation files.

Edit2:

like this
...
Label l;
WString ru_ru1=ToUnicode("Революция",255);
l.text=???(???,ru_ru1,???);
...

I've set the existing *.cpp file to UTF8.


Oooops. Looks like my explanation about "default-default" charset was wrong.... Perhaps because of backward compatibility, default-default is WIN1252 (which AFAIK is equal to ISO-8859-1) - code-pages used in US.

So what you need to do is SetDefaultCharset(CHARSET_UTF8); at the start of your code.

(Should I change this?)

There is no need to play with ToUnicode then, just use the UTF-8:

chrset::chrset()
{
	CtrlLayout(*this, "Window title");
	lbl1 = "řeřicha česky";
	lbl2 = "Революция";
	lbl3 = "∑∂¼đ";
}

GUI_APP_MAIN
{
	SetDefaultCharset(CHARSET_UTF8);
	chrset().Run();
}


Mirek

[Updated on: Sun, 06 August 2006 08:27]

Report message to a moderator

Re: How to display several languages without translation files? [message #4441 is a reply to message #4422] Tue, 08 August 2006 19:24 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
luzr wrote on Sun, 06 August 2006 07:26



Oooops. Looks like my explanation about "default-default" charset was wrong.... Perhaps because of backward compatibility, default-default is WIN1252 (which AFAIK is equal to ISO-8859-1) - code-pages used in US.

So what you need to do is SetDefaultCharset(CHARSET_UTF8); at the start of your code.

(Should I change this?)

There is no need to play with ToUnicode then, just use the UTF-8:

chrset::chrset()
{
	CtrlLayout(*this, "Window title");
	lbl1 = "řeřicha česky";
	lbl2 = "Революция";
	lbl3 = "∑∂¼đ";
}

GUI_APP_MAIN
{
	SetDefaultCharset(CHARSET_UTF8);
	chrset().Run();
}


Mirek



Thanks! At last (I think...) I understand Smile
===
U++, when compiling, doesn't use the same "brain part" which U++ editor uses... and doesn't know which encoding comes to its "mouth".
When compiling, you have to tell U++ "brain" which "mouth" to open by telling explicitly SetDefaultCharset(...).

Then you can manipulate the "digesting process" (and different "output products") with ToCharset, ToUnicode, ToUtf... etc.
===
Conclusive tip: To have WYSIWYG (what you see is what you get) you have to have the same encoding (eg. UTF8) for your file and SetDefaultCharset(...).
===
The scope of SetDefaultCharset(...) is your application (not package).
===
Is everything correct?

[P.S.Edited according to below... Smile]

[Updated on: Wed, 09 August 2006 17:13]

Report message to a moderator

Re: How to display several languages without translation files? [message #4443 is a reply to message #4441] Tue, 08 August 2006 20:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12735
Registered: November 2005
Ultimate Member
Beware, scope of SetDefaultCharset is the whole application (I cannot imagine how to limit its scope to package only....)

I guess this needs more explainint.

DefaultCharset is single global variable. Value of this variable is used on a couple of absolutely critical places to convert char to wchar and back when no explicit charset (codepage) is specified, namely:

String <-> WString
host OS text (e.g. filesystem names)
text translations via t_ function (all translations are stored in UTF-8, t_ translates them to current default charset).

Maybe I forgot something, but these three points are mostly enough to have your app in any encoding you need.

Speaking about UTF-8, note that U++ UTF-8 has a little "improvement" - standard UTF-8 has problem as not every combination of bytes is valid UTF-8 text (means you can have "UTF-8 format errors").

This causes stupid problem for UTF-8 capable editors (e.g. the source editor in TheIDE) - if you have a file that contains multiple encodings (why not...), you cannot open it in the editor.

Therefore, U++ extends UTF-8 to cover these cases by encoding "errors" using "Unicode private area" - 0xee00 - 0xeeff. This way, you can load and save such files without problems. (Nice name for this format is therefore UTF-8EE - could mean "error extension" and is the same as hex address Wink

Mirek
Re: How to display several languages without translation files? [message #4459 is a reply to message #4443] Wed, 09 August 2006 17:19 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
I edited my previous post. I had in mind "your package application" but then somehow (wrongly) assumed application==package.... Your post makes those things even more clear. Thanks.
Previous Topic: some non-english characters don't display
Next Topic: incorrect date format for hungarian language
Goto Forum:
  


Current Time: Wed Sep 30 08:33:18 CEST 2020

Total time taken to generate the page: 0.02070 seconds