Recent

Author Topic: EXCLUDE from translation, how?  (Read 506 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: 6147
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.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

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.