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 » Community » Newbie corner » Translation files
Translation files [message #54694] Tue, 01 September 2020 17:44 Go to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Hi guys,
I was going to internationalize my tool and I had a look at the online documentation (https://www.ultimatepp.org/srcdoc$Core$i18n$en-us.html and https://www.ultimatepp.org/srcdoc$Core$Translating$en-us.htm l) but it's not clear for me if there is an easy way to generate the .t file that includes all T_() macros present in my package.

Is there a good example to look at in the Bazaar to set this feature?

Thanks,
Matteo
Re: Translation files [message #54695 is a reply to message #54694] Tue, 01 September 2020 19:13 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
What you need to do is to add .t file to your package, then use "Project/Synchronize translation files...". TheIDE then scans through all packages and where it finds .t, scans all files for t_ texts. It would be probably wise at that point to uncheck all translation files that you do not want to update, leving just your .t file. Then there is Versions list - that one is editable. There you want to add all languages that you need. After pressing OK, TheIDE update all .t files that have check, adding empty definitions for all string/language combos that are not alredy defined.

Mirek
Re: Translation files [message #54706 is a reply to message #54695] Wed, 02 September 2020 11:03 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Good news! I forgot to add the .t file before running the "Synchronize translation file" and my package was not included in the list!

Thanks,
Matteo
Re: Translation files [message #54716 is a reply to message #54706] Thu, 03 September 2020 16:27 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Hi guys,
I'm here again... I made a test but I have a few problems changing the language setting inside the tool

I set the .t file that include (encoded UTF8)
#ifdef _MSC_VER
#pragma setlocale("C")
#endif

T_("Support")
itIT("Supporto")


I try to change the language with the function below:
void STDctrl::Language(void)
{
	MenuBar bar;	
	bar.MaxIconSize(Size(80,35)).LeftGap(85);
	bar.Add("Italiano", Images::Flag, THISBACK1(SetLang, 10));
	bar.Add("English", Images::Flag, THISBACK1(SetLang, 20));
	bar.Execute();
}

void STDctrl::SetLang(int i)
{
	switch(i) {
	case 10:
		SetLanguage(LNGC_('I','T','I','T', CHARSET_UNICODE));
		Refresh();
		break;
	case 20:
		SetLanguage(LNGC_('E','N','U','S', CHARSET_UNICODE));
		Refresh();
		break;
	default:
		SetLanguage(LNGC_('E','N','U','S', CHARSET_UNICODE));
		Refresh();
		break;
	}
}


and this:
GUI_APP_MAIN
{	
SetLanguage( GetSystemLNG());
}


When I open the software the "SetLanguage( GetSystemLNG())" function works and the tool display the italian translation "supporto" but if I try to call the function THISBACK1(SetLang, 10 or 20) nothing happen. Maybe I have to refresh something?

One more question, can I turn the default setting to italian and English as a second language with something like this?ù

T_("Supporto")
enUS("Support")


Thanks,
Matteo



Re: Translation files [message #54717 is a reply to message #54716] Thu, 03 September 2020 16:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
idkfa46 wrote on Thu, 03 September 2020 16:27


When I open the software the "SetLanguage( GetSystemLNG())" function works and the tool display the italian translation "supporto" but if I try to call the function THISBACK1(SetLang, 10 or 20) nothing happen. Maybe I have to refresh something?



Changing language requires restart, sorry. It would have performance impact otherwise.

You might perhaps organize things so that the application restarts itself after changing the language.

Quote:

One more question, can I turn the default setting to italian and English as a second language with something like this?ù

T_("Supporto")
enUS("Support")



Not possible - there is no info in t_ about the language or even package, so one language has to be "reference" one.

We could certainly do that, but that would complicate the whole process.

Mirek
Re: Translation files [message #54721 is a reply to message #54717] Thu, 03 September 2020 17:37 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
mirek wrote on Thu, 03 September 2020 16:55


Changing language requires restart, sorry. It would have performance impact otherwise.

You might perhaps organize things so that the application restarts itself after changing the language.



So fare the only solution is:
- remove the SetLanguage( GetSystemLNG()) at the software start
- store the user setting somewhere
- read the user setting at the software re-start

Thanks, I'll try... Laughing
Matteo
Re: Translation files [message #54722 is a reply to message #54721] Thu, 03 September 2020 18:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
idkfa46 wrote on Thu, 03 September 2020 17:37
mirek wrote on Thu, 03 September 2020 16:55


Changing language requires restart, sorry. It would have performance impact otherwise.

You might perhaps organize things so that the application restarts itself after changing the language.



So fare the only solution is:
- remove the SetLanguage( GetSystemLNG()) at the software start
- store the user setting somewhere
- read the user setting at the software re-start

Thanks, I'll try... Laughing
Matteo


Exactly!

Mirek
Re: Translation files [message #54865 is a reply to message #54694] Wed, 23 September 2020 11:22 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
It's working fine but when I import to my file.t accented characters the tool convert it as below:

T_("Stampa")
csCZ("Tisk")
enGB("Print")
esES("Impresi\303\263n")  -- ???? -- instead of esES("Impresión")
itIT("Stampa")


Why? If I close and open UPP again all come back to normality...

Thanks,
Matteo
Re: Translation files [message #54866 is a reply to message #54865] Wed, 23 September 2020 11:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
idkfa46 wrote on Wed, 23 September 2020 11:22
It's working fine but when I import to my file.t accented characters the tool convert it as below:


Import how? I will check...

This is probably some remnant of workaround for problems with some compilers that were not allowing >128 chars in strings...
Re: Translation files [message #54869 is a reply to message #54866] Wed, 23 September 2020 14:18 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
mirek wrote on Wed, 23 September 2020 11:46
idkfa46 wrote on Wed, 23 September 2020 11:22
It's working fine but when I import to my file.t accented characters the tool convert it as below:


Import how? I will check...

This is probably some remnant of workaround for problems with some compilers that were not allowing >128 chars in strings...


I just copy and paste from notepad...

Matteo
Re: Translation files [message #54870 is a reply to message #54694] Wed, 23 September 2020 14:25 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member


One more question... sometimes I find "// Obsolete" in my file.t

What does it mean?

Thanks,
Matteo
Re: Translation files [message #54871 is a reply to message #54870] Wed, 23 September 2020 16:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
idkfa46 wrote on Wed, 23 September 2020 14:25


One more question... sometimes I find "// Obsolete" in my file.t

What does it mean?

Thanks,
Matteo


It means that the english string (like t_("text to translate")) is not in project anymore.
Re: Translation files [message #54872 is a reply to message #54869] Wed, 23 September 2020 16:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
idkfa46 wrote on Wed, 23 September 2020 14:18
mirek wrote on Wed, 23 September 2020 11:46
idkfa46 wrote on Wed, 23 September 2020 11:22
It's working fine but when I import to my file.t accented characters the tool convert it as below:


Import how? I will check...

This is probably some remnant of workaround for problems with some compilers that were not allowing >128 chars in strings...


I just copy and paste from notepad...

Matteo


Cannot reproduce. What I have tried:

I have added test.t into some testing main package, added some t_("something"), did Project/Synchronize translation files.., added esES variant, then gone to test.t and copy&paste Impresión from here to test.t. Everything seems normal.

Where have I diverted from what you are doing?

Mirek
Re: Translation files [message #54874 is a reply to message #54872] Wed, 23 September 2020 16:38 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Mirek,

I can reproduce it - just open .t file then switch to hex edit and then go to text view again. All special symbols are dispayed as \${value}.

Klugier


U++ - one framework to rule them all.

[Updated on: Wed, 23 September 2020 16:38]

Report message to a moderator

Re: Translation files [message #54875 is a reply to message #54874] Wed, 23 September 2020 17:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Klugier wrote on Wed, 23 September 2020 16:38
Hello Mirek,

I can reproduce it - just open .t file then switch to hex edit and then go to text view again. All special symbols are dispayed as \${value}.

Klugier


After further investigation, as weird as it sounds this is OK. I am sorry I have forgot this over years.

Thing is, the text really is stored on the disk with those \xxx values as workaround for visual c++ compiler, which otherwise complains. However to make everything readable and editable, this conversion for .t files normally happens on load / save.

Now if you press Ctrl+B and then Ctrl+T, the problem is that Ctrl+T is command that forces to display file exactly as it is on disk (e.g. layout file). You can switch this by just pressing Ctrl+T, without Ctrl+B...

So maybe a bit confusing, but harmless...

Mirek

Re: Translation files [message #54878 is a reply to message #54694] Wed, 23 September 2020 17:32 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member

Got it, thanks!

Matteo
Re: Translation files [message #54900 is a reply to message #54875] Sun, 27 September 2020 00:15 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Mirek,

After today analyzing of ide tool bar. I came into conclusion that the designed behavior of handling translation file is as follow:
- text editing (it displays special numbers)
- designer mode (it displays symbols correctly without special numbers), however in UI it is treated as text mode... (second text mode with no UI representation...)

So, what we should do in this case is representing "designer" state for .t file (Right now it is interpreted as text and this is misleading for our users).

Take a look at this screenshot
index.php?t=getfile&id=6227&private=0

Matteo thanks for reporting.

Klugier


U++ - one framework to rule them all.

[Updated on: Sun, 27 September 2020 01:17]

Report message to a moderator

Re: Translation files [message #54941 is a reply to message #54694] Wed, 30 September 2020 12:31 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
I'm here again! The tranlsation mode works very well but I'm in trouble with my database...
When I change the language the t_() content inside the db do not change and I have a few queries that fail!


here is an example:


void Impostazioni::ResetDbCoefCombinaz()
{
	SQL & Delete(COEFCOMBIN);
	
	int i=0;
	Progress p(t_("Creating database: coefficienti di combinazione..."));
	
	try
	{
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Carichi permanenti"))(PSI0j,0)(PSI1j,0)(PSI2j,0); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Carichi permanenti NON strutturali"))(PSI0j,0)(PSI1j,0)(PSI2j,0); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Categoria A Ambienti ad uso residenziale"))(PSI0j,0.70)(PSI1j,0.50)(PSI2j,0.30); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Categoria B Uffici"))(PSI0j,0.70)(PSI1j,0.50)(PSI2j,0.30); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Categoria C Ambienti suscettibili di affollamento"))(PSI0j,0.70)(PSI1j,0.70)(PSI2j,0.60); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Categoria D Ambienti ad uso commerciale"))(PSI0j,0.70)(PSI1j,0.70)(PSI2j,0.60); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Categoria E Biblioteche, archivi, magazzini e ambienti ad uso industriale"))(PSI0j,1.00)(PSI1j,0.90)(PSI2j,0.80); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Categoria F Rimesse e parcheggi (per autoveicoli di peso <= 30 kN)"))(PSI0j,0.70)(PSI1j,0.70)(PSI2j,0.60); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Categoria G Rimesse e parcheggi (per autoveicoli di peso > 30 kN)"))(PSI0j,0.70)(PSI1j,0.50)(PSI2j,0.30); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Categoria H Coperture"))(PSI0j,0.00)(PSI1j,0.00)(PSI2j,0.00); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Vento"))(PSI0j,0.60)(PSI1j,0.20)(PSI2j,0.00); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Neve (a quota <= 1000 m s.l.m.)"))(PSI0j,0.50)(PSI1j,0.20)(PSI2j,0.00); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Neve (a quota > 1000 m s.l.m.)"))(PSI0j,0.70)(PSI1j,0.50)(PSI2j,0.20); p.SetPos(++i);
		SQL & Insert(COEFCOMBIN)(CATEGORIA,t_("Variazioni termiche"))(PSI0j,0.60)(PSI1j,0.50)(PSI2j,0.00); p.SetPos(++i);
	}
	catch(SqlExc &e)
	{
		Exclamation("[* " + DeQtfLf(e) + "]");
	}
}

double Impostazioni::GetPsi0j(String s)
{
	SQL * Select(PSI0j).From(COEFCOMBIN).Where(CATEGORIA == s);	return SQL[PSI0j];
}




Is there any trick to solve it or to force the language update?

Thanks,
Matteo
Re: Translation files [message #54964 is a reply to message #54941] Fri, 02 October 2020 08:51 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
The only solution I have found till now is to reset the database at the language change... it's not the best solution in my mind because I lose possible user settings Sad

Matteo
Re: Translation files [message #54965 is a reply to message #54964] Fri, 02 October 2020 11:24 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
idkfa46 wrote on Fri, 02 October 2020 08:51
The only solution I have found till now is to reset the database at the language change... it's not the best solution in my mind because I lose possible user settings Sad

Matteo


Sorry I have not replied sooner, but it is not at all clear to me what you are trying to achieve...

Now it seems like you have some texts in database and you want these to change based on current language?

If these are there, the Insert really is not the SQL command you want to use. What about Update? (of course, you need to insert these records first) Smile

Mirek

[Updated on: Fri, 02 October 2020 11:24]

Report message to a moderator

Previous Topic: Simple Thread
Next Topic: Create exe from Windows to Linux
Goto Forum:
  


Current Time: Thu Mar 28 20:04:54 CET 2024

Total time taken to generate the page: 0.02038 seconds