Recent

Author Topic: EXCLUDE from translation, how?  (Read 7196 times)

CTekk

  • Newbie
  • Posts: 2
EXCLUDE from translation, how?
« 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.

wp

  • Hero Member
  • *****
  • Posts: 11915
Re: EXCLUDE from translation, how?
« Reply #1 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.

CTekk

  • Newbie
  • Posts: 2
Re: EXCLUDE from translation, how?
« Reply #2 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.

Zaher

  • Hero Member
  • *****
  • Posts: 680
    • parmaja.org
Re: EXCLUDE from translation, how?
« Reply #3 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
« Last Edit: November 05, 2020, 03:45:53 pm by Zaher »

wp

  • Hero Member
  • *****
  • Posts: 11915
Re: EXCLUDE from translation, how?
« Reply #4 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.

Zaher

  • Hero Member
  • *****
  • Posts: 680
    • parmaja.org
Re: EXCLUDE from translation, how?
« Reply #5 on: November 05, 2020, 10:45:15 pm »
« Last Edit: November 06, 2020, 07:24:44 pm by Zaher »

 

TinyPortal © 2005-2018