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 Internationalize my app?
how to Internationalize my app? [message #3332] Sat, 20 May 2006 17:37 Go to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

the application is almost ready. Now I would like to make it international. I've read the document "Internationalization and translation files" but I need some other hint. For the moment I've marked with t_("...") the string of the application where I want should appear some other language.
I would like to provvide several translation files that the user can modify as he likes. Once he set one language each time the application run with the same language. For the moment let's talk only about Italian translation. I guess I must use UTF8 code (I want to support even Russian alphabet).

If I've understood I have to produce a translation file for each language. Unfortunatly I've not been able to export a .tr file with t_(...) string of my application. I've tried
myapp --export-tr itit-

but the file obtained didn't contain my t_(...) but only those of the U++ library. Where I do mistake?

Luigi

[Updated on: Sat, 20 May 2006 17:41]

Report message to a moderator

Re: how to Internationalize my app? [message #3333 is a reply to message #3332] Sat, 20 May 2006 20:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
forlano wrote on Sat, 20 May 2006 11:37

Hello,

the application is almost ready. Now I would like to make it international. I've read the document "Internationalization and translation files" but I need some other hint. For the moment I've marked with t_("...") the string of the application where I want should appear some other language.
I would like to provvide several translation files that the user can modify as he likes. Once he set one language each time the application run with the same language. For the moment let's talk only about Italian translation. I guess I must use UTF8 code (I want to support even Russian alphabet).

If I've understood I have to produce a translation file for each language. Unfortunatly I've not been able to export a .tr file with t_(...) string of my application. I've tried
myapp --export-tr itit-

but the file obtained didn't contain my t_(...) but only those of the U++ library. Where I do mistake?

Luigi



You must add ".t" file to your package and invoke "Project/Synchronize translation files".

You do not need to make commandline export - that is good for translating U++ or app you do not have sources for, but not necessary for translating your app. Instead it is easier to use TheIDE to add languages in "Synchronize" and then edit .t directly.

Mirek

[Updated on: Sat, 20 May 2006 20:54]

Report message to a moderator

Re: how to Internationalize my app? [message #3339 is a reply to message #3333] Sat, 20 May 2006 23:17 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Sat, 20 May 2006 20:54



You must add ".t" file to your package and invoke "Project/Synchronize translation files".

You do not need to make commandline export - that is good for translating U++ or app you do not have sources for, but not necessary for translating your app. Instead it is easier to use TheIDE to add languages in "Synchronize" and then edit .t directly.

Mirek


I'm very Very Happy ... here is my achievement:
// Vega.lay

T_("Edit Player")
deDE("")
itIT("")
ruRU("")

T_("Name")
deDE("")
itIT("Nome")
ruRU("˜¼")

T_("Fed")
deDE("")
itIT("")
ruRU("")
...

It is very easy (knowing what to do Smile ). Now the last thing please. By default the menu is an English but which command I have to run to make active, say, "itIT" translation at runtime when the user choose the Italian language?
By Navigate I have found
 
 SetLanguage(int lang);

I hoped that 'lang' was some index in the .t file but I was unlucky.

Luigi
Re: how to Internationalize my app? [message #3340 is a reply to message #3339] Sat, 20 May 2006 23:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
forlano wrote on Sat, 20 May 2006 17:17

luzr wrote on Sat, 20 May 2006 20:54



You must add ".t" file to your package and invoke "Project/Synchronize translation files".

You do not need to make commandline export - that is good for translating U++ or app you do not have sources for, but not necessary for translating your app. Instead it is easier to use TheIDE to add languages in "Synchronize" and then edit .t directly.

Mirek


I'm very Very Happy ... here is my achievement:
// Vega.lay

T_("Edit Player")
deDE("")
itIT("")
ruRU("")

T_("Name")
deDE("")
itIT("Nome")
ruRU("˜¼")

T_("Fed")
deDE("")
itIT("")
ruRU("")
...

It is very easy (knowing what to do Smile ). Now the last thing please. By default the menu is an English but which command I have to run to make active, say, "itIT" translation at runtime when the user choose the Italian language?
By Navigate I have found
 
 SetLanguage(int lang);

I hoped that 'lang' was some index in the .t file but I was unlucky.

Luigi


Well, you was near:

SetLanguage(LNG_('D','E','D','E'));

Mirek
Re: how to Internationalize my app? [message #3342 is a reply to message #3340] Sun, 21 May 2006 00:19 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Sat, 20 May 2006 23:23



Well, you was near:

SetLanguage(LNG_('D','E','D','E'));

Mirek

I'm sorry to bother you again with this topic, but perhaps I'm missing something else... the message file, message.t, is in the same folder of the executable and I've added some Italian words. When I run
void VegaMain::SelectLanguage()
{
  SetLanguage( LNG_('I','T','I','T') );
}

The message continue to be in English even if it present the Italian one. Maybe I must force in some way the reading of the message.t file or indicate to the app that it exists.

Luigi
Re: how to Internationalize my app? [message #3343 is a reply to message #3342] Sun, 21 May 2006 07:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
forlano wrote on Sat, 20 May 2006 18:19

luzr wrote on Sat, 20 May 2006 23:23



Well, you was near:

SetLanguage(LNG_('D','E','D','E'));

Mirek

I'm sorry to bother you again with this topic, but perhaps I'm missing something else... the message file, message.t, is in the same folder of the executable and I've added some Italian words. When I run
void VegaMain::SelectLanguage()
{
  SetLanguage( LNG_('I','T','I','T') );
}

The message continue to be in English even if it present the Italian one. Maybe I must force in some way the reading of the message.t file or indicate to the app that it exists.

Luigi



Sorry, my fault....

First, .t should be in your package dir like all other source files. It gets compiled into the .exe.

Second, I forgot to mention that you have to include .t file somewhere in sources (not headers) like

#define  TFILE <CtrlLib/CtrlLib.t>
#include <Core/t.h>


If you have any non-main package, place this into .icpp file so that it is forced to be linked always. Anyway, if you are doing so for the main package, it is enough to place it to the .cpp with GUI_APP_MAIN (that one gets linked always).

Mirek

Re: how to Internationalize my app? [message #3346 is a reply to message #3343] Sun, 21 May 2006 09:13 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Sun, 21 May 2006 07:53


Sorry, my fault....

First, .t should be in your package dir like all other source files. It gets compiled into the .exe.

Second, I forgot to mention that you have to include .t file somewhere in sources (not headers) like

#define  TFILE <CtrlLib/CtrlLib.t>
#include <Core/t.h>


If you have any non-main package, place this into .icpp file so that it is forced to be linked always. Anyway, if you are doing so for the main package, it is enough to place it to the .cpp with GUI_APP_MAIN (that one gets linked always).

Mirek


It continues to not work Sad . Here is the HelloWorld example modified in view of the use of the file message.t. This example, once it works, could be an example about the topic we are discussing.
#include <CtrlLib/CtrlLib.h>


#define  TFILE <HelloWorld/message.t> //<mypackage directory/my_t_file_with_translation
#include <Core/t.h>

class HelloWorld : public TopWindow {
	MenuBar menu;
	StatusBar status;

	void FileMenu(Bar& bar);
	void MainMenu(Bar& bar);
	void About();
        void CloseCB();
public:
	typedef HelloWorld CLASSNAME;

	HelloWorld();
};

void HelloWorld::About()
{
	PromptOK(t_("{{1@5 [@9= This is the]::@2 [A5@0 Ultimate`+`+ Hello world sample}}"));
}

void HelloWorld::CloseCB()
{
	if(PromptYesNo(t_("Are you sure?"))) Close(); 
}

void HelloWorld::FileMenu(Bar& bar)
{
	bar.Add(t_("About.."), THISBACK(About));
	bar.Separator();
	bar.Add(t_("Exit"), THISBACK(CloseCB));
}

void HelloWorld::MainMenu(Bar& bar)
{
	menu.Add(t_("File"), THISBACK(FileMenu));
}

HelloWorld::HelloWorld()
{
	AddFrame(menu);
	AddFrame(status);
	menu.Set(THISBACK(MainMenu));
	status = t_("Welcome to the Ultimate++ !");	
}

GUI_APP_MAIN
{
//	SetLanguage(LNG_ENGLISH);
	SetLanguage(LNG_('I','T','I','T') );
	HelloWorld().Run();
}

So I've marked the string with t_(...), I've included what you signaled the last time, then I set the Italian language. Moreover I've generated the file message.t by using Sincronize... This is the file:
// hello.cpp

T_("{{1@5 [@9= This is the]::@2 [A5@0 Ultimate`+`+ Hello world sample}}")
itIT("{{1@5 [@9= Questa e' l'esempio]::@2 [A5@0 di Ultimate`+`+ Hello world}}")

T_("Are you sure?")
itIT("Sei sicuro?")

T_("About..")
itIT("A proposito...")

T_("Exit")
itIT("Esci")

T_("File")
itIT("FILE")

T_("Welcome to the Ultimate++ !")
itIT("Benvenuto in Ultimate++ !")

It stays in the package directory. However no sign of Italian strings in the application. BTW, I've even tried some other combination of includes without success. What am I missing?

Luigi

edit: this file has been updated with the correction of the next reply from Mirek. Now it works

[Updated on: Sun, 21 May 2006 11:38]

Report message to a moderator

Re: how to Internationalize my app? [message #3347 is a reply to message #3346] Sun, 21 May 2006 10:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
forlano wrote on Sun, 21 May 2006 03:13


#define TFILE <CtrlLib/CtrlLib.t>
#include <Core/t.h>
[/code]



Sorry for confusing you, TFILE here is just an example (copied straight from CtrlLib package), it should point to your .t (inside your package).

Mirek
Re: how to Internationalize my app? [message #3349 is a reply to message #3347] Sun, 21 May 2006 11:35 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Sun, 21 May 2006 10:00

forlano wrote on Sun, 21 May 2006 03:13


#define TFILE <CtrlLib/CtrlLib.t>
#include <Core/t.h>
[/code]



Sorry for confusing you, TFILE here is just an example (copied straight from CtrlLib package), it should point to your .t (inside your package).

Mirek


OK, now it works Smile , but there is still a new problem that I didn't expect. The following translation works:
T_("{{1@5 [@9= This is the]::@2 [A5@0 Ultimate`+`+ Hello world sample}}")
itIT("{{1@5 [@9= Questa e' l'esempio]::@2 [A5@0 di Ultimate`+`+ Hello world}}")

But I've used a workround to let it to work. In fact instead of "e'" I should use "" ('e' with accent all in one character). But this produces the following message:
"ERROR: invalid UTF-8 sequence..."
Is this normal?

In order to change all the interface message at the start of the application I guess I need to save the selected language change in a configuration file.

Last consideration. In this way the message.t file is compiled and the user has not the possibility to change the translation if it has not the source code of the application. I wonder if in U++ there is a smart way to distribute the application with some message file that the user can modify as it likes. For example he can fill all the ruRU translation without to bother me asking a new compilation. This file should be loaded by the application when it starts. I've done it for my old app, but with t_(...) his manteinance should be greatly simplified.

Luigi
Re: how to Internationalize my app? [message #3350 is a reply to message #3349] Sun, 21 May 2006 12:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
forlano wrote on Sun, 21 May 2006 05:35

luzr wrote on Sun, 21 May 2006 10:00

forlano wrote on Sun, 21 May 2006 03:13


#define TFILE <CtrlLib/CtrlLib.t>
#include <Core/t.h>
[/code]



Sorry for confusing you, TFILE here is just an example (copied straight from CtrlLib package), it should point to your .t (inside your package).

Mirek


OK, now it works Smile , but there is still a new problem that I didn't expect. The following translation works:
T_("{{1@5 [@9= This is the]::@2 [A5@0 Ultimate`+`+ Hello world sample}}")
itIT("{{1@5 [@9= Questa e' l'esempio]::@2 [A5@0 di Ultimate`+`+ Hello world}}")

But I've used a workround to let it to work. In fact instead of "e'" I should use "" ('e' with accent all in one character). But this produces the following message:
"ERROR: invalid UTF-8 sequence..."
Is this normal?

In order to change all the interface message at the start of the application I guess I need to save the selected language change in a configuration file.

Last consideration. In this way the message.t file is compiled and the user has not the possibility to change the translation if it has not the source code of the application. I wonder if in U++ there is a smart way to distribute the application with some message file that the user can modify as it likes. For example he can fill all the ruRU translation without to bother me asking a new compilation. This file should be loaded by the application when it starts. I've done it for my old app, but with t_(...) his manteinance should be greatly simplified.

Luigi


Is your .t file in UTF-8? It MUST be!

To change encoding of file, go to "Project/File properties". Alternatively, you can do that in package organizer, even for the whole package.

As for modifying message files, yes - that is that commandline thing decribed in Internationalization topic. Plus, you can import it back to TheIDE and place strings to .t files using "Project/Import runtime translation files".

Mirek
Re: how to Internationalize my app? [message #3353 is a reply to message #3350] Sun, 21 May 2006 13:48 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Sun, 21 May 2006 12:22


Is your .t file in UTF-8? It MUST be!

To change encoding of file, go to "Project/File properties". Alternatively, you can do that in package organizer, even for the whole package.



It was set to "default". I set it to "UTF-8" and run the synchronization. Now it works!

Quote:


As for modifying message files, yes - that is that commandline thing decribed in Internationalization topic. Plus, you can import it back to TheIDE and place strings to .t files using "Project/Import runtime translation files".

Mirek



I've generated the file itit-t.tr by the command line
HelloWorld.exe --export-tr  itit-

Now I believed that modifying the itit-t.tr file I could update the internal message.t file I used at compile time. Instead nothing!
After some time and test I've discovered that the .tr file is used only if the .t file has empty translation for some item. In other words, where .t has already its own translation the corrispondent item in .tr is ignored.
This means that if one would give free hand to the user should prepare a .t file all with empty translation, and support it via .tr file. Am I right?

Luigi

[Updated on: Sun, 21 May 2006 13:48]

Report message to a moderator

Re: how to Internationalize my app? [message #3355 is a reply to message #3353] Sun, 21 May 2006 14:17 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
forlano wrote on Sun, 21 May 2006 07:48

luzr wrote on Sun, 21 May 2006 12:22


Is your .t file in UTF-8? It MUST be!

To change encoding of file, go to "Project/File properties". Alternatively, you can do that in package organizer, even for the whole package.



It was set to "default". I set it to "UTF-8" and run the synchronization. Now it works!

Quote:


As for modifying message files, yes - that is that commandline thing decribed in Internationalization topic. Plus, you can import it back to TheIDE and place strings to .t files using "Project/Import runtime translation files".

Mirek



I've generated the file itit-t.tr by the command line
HelloWorld.exe --export-tr  itit-

Now I believed that modifying the itit-t.tr file I could update the internal message.t file I used at compile time. Instead nothing!
After some time and test I've discovered that the .tr file is used only if the .t file has empty translation for some item. In other words, where .t has already its own translation the corrispondent item in .tr is ignored.
This means that if one would give free hand to the user should prepare a .t file all with empty translation, and support it via .tr file. Am I right?

Luigi


Yes, that is correct. You can however add those empty translations easily in Synchronize....

BTW, you can do so even later, all translations ever used are stored in special file. That means, if you are adding new language and translation is already in that database, it is inserted automatically.

Mirek
Re: how to Internationalize my app? [message #12181 is a reply to message #3332] Mon, 15 October 2007 20:22 Go to previous messageGo to next message
tvanriper is currently offline  tvanriper
Messages: 85
Registered: September 2007
Location: Germantown, MD, USA
Member
Thankfully, this topic existed, and I was able to get an application I created to work correctly in Spanish (I think), but I wonder if we couldn't modify the following web page a little bit, to help improve (just a touch) the documentation:

http://www.ultimatepp.org/srcdoc$Core$i18n$en-us.html

Here, it would be useful to know:

1. You need the following in one of the .cpp or .icpp files:

#define <YourProject/YourTranslations.t>
#include <Core/t.h>


2. You should set your application's default language using the following:

::SetLanguage( ::GetSystemLNG() );


(or am I wrong about this?)

3. Your various valid language codes (e.g. "esES" is Spanish) are available in Core as 'lcid.txt' within the Language area.

4. You can set your .t file's encoding by right-clicking on the file in TheIDE and selecting "Convert to encoding...", to ensure that it's set for UTF-8. I think you have to strip out the BOM that Windows might include for UTF-8 if you use Notepad to save your file in UTF-8 encoding, as I think you'll have problems compiling, otherwise.
Re: how to Internationalize my app? [message #12202 is a reply to message #12181] Wed, 17 October 2007 19:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
tvanriper wrote on Mon, 15 October 2007 14:22

Thankfully, this topic existed, and I was able to get an application I created to work correctly in Spanish (I think), but I wonder if we couldn't modify the following web page a little bit, to help improve (just a touch) the documentation:



Well, you have got the article in Core/srcdoc.tpp/i18n - perhaps you can fix it and post here...

Mirek
Re: how to Internationalize my app? [message #12227 is a reply to message #3332] Fri, 19 October 2007 15:13 Go to previous messageGo to next message
tvanriper is currently offline  tvanriper
Messages: 85
Registered: September 2007
Location: Germantown, MD, USA
Member
Okay, hopefully I got this right (I'm not terribly familiar with Topic++ yet).

I've included a zipped file with the .tdx (for upp/cfg) and .tpp (for upp/uppsrc/Core/srcdoc.tpp).

Hopefully, if I didn't err in the files I'm providing, this should add some detail for the four items I mentioned earlier.

Please let me know of any problems.
Re: how to Internationalize my app? [message #12229 is a reply to message #12227] Fri, 19 October 2007 18:09 Go to previous message
mirek is currently offline  mirek
Messages: 12126
Registered: November 2005
Ultimate Member
Thank you, you did OK Wink

Note: No need to post .tdx file.... This is only cached indexing info..

Mirek
Previous Topic: Non-english symbols unreadable [solved w/ SetDefaultCharset]
Next Topic: Spacing problems with FileSel...
Goto Forum:
  


Current Time: Sat Dec 14 20:30:22 CET 2019

Total time taken to generate the page: 0.01501 seconds