Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Change runtime FMX.Consts


This question is answered.


Permlink Replies: 7 - Last Post: Jul 12, 2016 11:41 PM Last Post By: Markus Humm
Nicolò Blunda

Posts: 23
Registered: 7/20/10
Change runtime FMX.Consts  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 10, 2016 10:39 PM
There is a way for assign to strings in FMX.Consts differents values runtime?
It is easy with compiler directive, when app/exe versions are differents (for example MyApp_EN and MyApp_IT).
If user, instead, wants to change langue with classic dropbox with flags (placed in MainForm of application), labels of MessageBox are not upgradables.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Change runtime FMX.Consts  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 10:09 AM   in response to: Nicolò Blunda in response to: Nicolò Blunda
Nicolò wrote:

There is a way for assign to strings in FMX.Consts differents values
runtime?

No. They are resource strings, they are constant values, they cannot be
modified at runtime.

It is easy with compiler directive, when app/exe versions are
differents (for example MyApp_EN and MyApp_IT).

The primary reason for using resource strings is localization. You don't
need compiler directives for that. Localized resources are loaded dynamically
at runtime.

If user, instead, wants to change langue with classic dropbox with
flags (placed in MainForm of application), labels of MessageBox are
not upgradables.

That is a different issue. That would have to be FMX not re-loading the
appropriate localized resources after a language change occurs. That would
be a framework bug, so report it to Quality Portal.

--
Remy Lebeau (TeamB)

Nicolò Blunda

Posts: 23
Registered: 7/20/10
Re: Change runtime FMX.Consts  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 1:02 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you for your answer, Remy.
But, maybe, i don't know how apply correctly the "localisation"...
After user set language value from "TComboBox with flags", what variable it is necessary to set inside code, in "OnChange" handler?
Note that it is not important the OS language. User can use OS in a EN version of Windows, for example, and want to use app in French or Italian...

Remy Lebeau (TeamB) wrote:
Nicolò wrote:

There is a way for assign to strings in FMX.Consts differents values
runtime?

No. They are resource strings, they are constant values, they cannot be
modified at runtime.

It is easy with compiler directive, when app/exe versions are
differents (for example MyApp_EN and MyApp_IT).

The primary reason for using resource strings is localization. You don't
need compiler directives for that. Localized resources are loaded dynamically
at runtime.

If user, instead, wants to change langue with classic dropbox with
flags (placed in MainForm of application), labels of MessageBox are
not upgradables.

That is a different issue. That would have to be FMX not re-loading the
appropriate localized resources after a language change occurs. That would
be a framework bug, so report it to Quality Portal.

--
Remy Lebeau (TeamB)

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Change runtime FMX.Consts  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 1:10 PM   in response to: Nicolò Blunda in response to: Nicolò Blunda
Nicolò wrote:

After user set language value from "TComboBox with flags", what
variable it is necessary to set inside code, in "OnChange" handler?

Note that it is not important the OS language. User can use OS in a EN
version of Windows, for example, and want to use app in French or
Italian...

Use the TLang component:

http://docwiki.embarcadero.com/Libraries/en/FMX.Types.TLang

For example:

http://docwiki.embarcadero.com/CodeExamples/en/FMXTLang_(Delphi)

--
Remy Lebeau (TeamB)
Nicolò Blunda

Posts: 23
Registered: 7/20/10
Re: Change runtime FMX.Consts  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 12, 2016 1:23 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you.
But TLang (interface) have some problem on RadStudio Seattle...
And I don't understand how he can translate consts for system messages (the only translation I need...)..
Where are "localized consts" (in installation fodler of embarcadero)? I don't find them...

Remy Lebeau (TeamB) wrote:
Nicolò wrote:

After user set language value from "TComboBox with flags", what
variable it is necessary to set inside code, in "OnChange" handler?

Note that it is not important the OS language. User can use OS in a EN
version of Windows, for example, and want to use app in French or
Italian...

Use the TLang component:

http://docwiki.embarcadero.com/Libraries/en/FMX.Types.TLang

For example:

http://docwiki.embarcadero.com/CodeExamples/en/FMXTLang_(Delphi)

--
Remy Lebeau (TeamB)
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Change runtime FMX.Consts
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 12, 2016 10:41 AM   in response to: Nicolò Blunda in response to: Nicolò Blunda
Am 12.07.2016 um 10:23 schrieb Nicolò Blunda:
Thank you.
But TLang (interface) have some problem on RadStudio Seattle...
And I don't understand how he can translate consts for system messages (the only translation I need...)..
Where are "localized consts" (in installation fodler of embarcadero)? I don't find them...


Hello,

1. the issue you most likely refer to is afaik fixed in berlin, but ok
TLang is not too nice

2. There are 3rd party solutions which can scan your project, build a
table with the strings and let you thranslate them. Those tools
(e.g. Multilizer) can create a .lng file. This can be loaded into
TLang.

3. When using TLang be sure to wrap all strings you output in code
like: ShowMessage('My text'); into translate calls:
ShowMessage(Translate('My text'));

4. Those conts (for instance those used for TMessageDlg's buttons)
cannot be translated. This is a bug and I already reported it:
https://quality.embarcadero.com/browse/RSP-13984
You may want to vote for it and monitor it.

Greetings

Markus
Nicolò Blunda

Posts: 23
Registered: 7/20/10
Re: Change runtime FMX.Consts  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 12, 2016 10:14 PM   in response to: Markus Humm in response to: Markus Humm
Thank you, Markus,
Now it is clear why my efforts (for release 4) have not been successful.

Markus Humm wrote:
Am 12.07.2016 um 10:23 schrieb Nicolò Blunda:
Thank you.
But TLang (interface) have some problem on RadStudio Seattle...
And I don't understand how he can translate consts for system messages (the only translation I need...)..
Where are "localized consts" (in installation fodler of embarcadero)? I don't find them...


Hello,

1. the issue you most likely refer to is afaik fixed in berlin, but ok
TLang is not too nice

2. There are 3rd party solutions which can scan your project, build a
table with the strings and let you thranslate them. Those tools
(e.g. Multilizer) can create a .lng file. This can be loaded into
TLang.

3. When using TLang be sure to wrap all strings you output in code
like: ShowMessage('My text'); into translate calls:
ShowMessage(Translate('My text'));

4. Those conts (for instance those used for TMessageDlg's buttons)
cannot be translated. This is a bug and I already reported it:
https://quality.embarcadero.com/browse/RSP-13984
You may want to vote for it and monitor it.

Greetings

Markus
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Change runtime FMX.Consts  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 12, 2016 11:41 PM   in response to: Nicolò Blunda in response to: Nicolò Blunda
Am 13.07.2016 um 07:14 schrieb Nicolò Blunda:
Thank you, Markus,
Now it is clear why my efforts (for release 4) have not been successful.

Hello,

one little thing: would you please write your answers below the text
you're answering to in the future? This is not e-mail where your style
is being preferred. Thanks.

Did you vote for my request to get these TMessageDlg texts translateable?

Greetings

Markus
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02