Lazarus

Miscellaneous => Translations => Topic started by: CTekk on June 21, 2019, 06:38:19 pm

Title: EXCLUDE from translation, how?
Post by: CTekk on June 21, 2019, 06:38:19 pm
Good evening. I am currently translating my application, but I have a problem. I have no idea how to exclude anything from translation. The problem is that I load settings and strings at the start of the application. But if the user changes language it destroys any data that the user has put in after the load when changing language.

There is an exclude memo in the project options i18n tab, but I have no clue how that should work. So basically, how would I go about excluding for example Edit1.text and Edit2.text from translation?

Any help is much apreciated.
Title: Re: EXCLUDE from translation, how?
Post by: wp on June 21, 2019, 06:48:00 pm
How do you manage the translations? With LCLTranslator/DefaultTranslator? In this case I don't understand why Edit1.Text and Edit2.Text are translated at all? IIRC, the translator only takes care of static strings, e.g. Label.Caption, Form.Caption etc.

You have best control over the strings to be translated when you define the strings as resource strings only and do not use automatic translation by LCLTranslator, but translate manually by calling TranslateUnitResourceStrings in unit Translations.
Title: Re: EXCLUDE from translation, how?
Post by: CTekk on June 21, 2019, 07:16:06 pm
How do you manage the translations? With LCLTranslator/DefaultTranslator? In this case I don't understand why Edit1.Text and Edit2.Text are translated at all? IIRC, the translator only takes care of static strings, e.g. Label.Caption, Form.Caption etc.

You have best control over the strings to be translated when you define the strings as resource strings only and do not use automatic translation by LCLTranslator, but translate manually by calling TranslateUnitResourceStrings in unit Translations.

Thanks for replying. I added LCLTranslator in the uses and untranslated text was translated back to the original text that I was using as a default value when building the application.

However, I solved this problem just now by adding 'TMyForm' in front of Edit1.text so it says this in the exclude memo now: 'TMyForm.Edit1.text' instead of 'Edit1.text' and this solved the problem. I Don't know how I could miss this but I did. I'm really sorry for wasting your time but this translating business is new to me.

Maybe this will be helpfull to others at least. Thanks once again for responding.
Title: Re: EXCLUDE from translation, how?
Post by: Zaher on November 05, 2020, 03:28:27 pm
Same question, I want Mylabel.caption not being translated
I m using LCLTranslator
Also problem MyComoboBox reset to ItemIndex = 0 after I change the language

In my old Delphi project I ignore all control that name started with _
And added IgnoreList to ignore controls in that form in this list
Title: Re: EXCLUDE from translation, how?
Post by: wp on November 05, 2020, 04:43:22 pm
You can use the i18n settings in the Project Options where you can specify a list of strings to be excluded from translation. Have a look at the translation demo in the examples folder of your Lazarus installation.
Title: Re: EXCLUDE from translation, how?
Post by: Zaher on November 05, 2020, 10:45:15 pm
ah, ty,
It maybe good idea to add it to the wiki
https://wiki.freepascal.org/Step-by-step_instructions_for_creating_multi-language_applications#Translating

I added it
TinyPortal © 2005-2018