Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-12

How to get the current translation of a resource string?

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

Since I want to treat a specific exception that cannot be distinguished by the class alone but only by the class and message, I need to find the current translation of the resource string used to create the exception.

The documentation at

https://www.freepascal.org/docs-html/current/prog/progse40.html

mentions ResourceStringTableCount, ResourceStringCount, GetResourceStringCurrentValue but I can't find them anywhere in my copy of fpc 3.2.0 (they are in fpc 2.6.4 and 3.0.4).

Bye

Luca

Reply by email

Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 11 lines
Since I want to treat a specific exception that cannot be distinguished by the class alone but only by the class and message, I need to find the current translation of the resource string used to create the exception. The documentation at https://www.freepascal.org/docs-html/current/prog/progse40.html mentions ResourceStringTableCount, ResourceStringCount, GetResourceStringCurrentValue but I can't find them anywhere in my copy of fpc 3.2.0 (they are in fpc 2.6.4 and 3.0.4).

I already did corrections on the documentation for this.

But the 'current translation' is simply the value of the resourcestring, so you should not need to look it up ?

Michael.

Reply by email

Luca Olivetti
to Michael Van Canneyt

El 2/12/20 a les 11:49, Michael Van Canneyt via fpc-pascal ha escrit:

Show quoted text 21 lines
On Tue, 1 Dec 2020, Luca Olivetti via fpc-pascal wrote: > Since I want to treat a specific exception that cannot be > distinguished by the class alone but only by the class and message, I > need to find the current translation of the resource string used to > create the exception. > > The documentation at > > https://www.freepascal.org/docs-html/current/prog/progse40.html > > mentions ResourceStringTableCount, ResourceStringCount, > GetResourceStringCurrentValue but I can't find them anywhere in my > copy of fpc 3.2.0 (they are in fpc 2.6.4 and 3.0.4). I already did corrections on the documentation for this. But the 'current translation' is simply the value of the resourcestring, so you should not need to look it up ?

How?

I'm trying to detect this specific exception

       raise EInvalidOperation.Create(sCannotFocus);

(where sCannotFocus is defined in LCLStrConsts).

I tried

   if E is EInvalidOperation then
      if E.message=sCannotFocus

but it doesn't work (sCannotFocus holds the original, not the translated, string).

Bye

Luc<

Reply by email

Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 18 lines
> But the 'current translation' is simply the value of the resourcestring, so > you should not need to look it up ? How? I'm trying to detect this specific exception raise EInvalidOperation.Create(sCannotFocus); (where sCannotFocus is defined in LCLStrConsts). I tried if E is EInvalidOperation then if E.message=sCannotFocus but it doesn't work (sCannotFocus holds the original, not the translated, string).

Seems like Lazarus is not using the regular resourcestrings then, because the whole point of using resourcestrings is that their value is the translated value...

Michael.

Reply by email

Luca Olivetti
to Michael Van Canneyt

El 2/12/20 a les 13:30, Michael Van Canneyt via fpc-pascal ha escrit:

Show quoted text 27 lines
On Wed, 2 Dec 2020, Luca Olivetti via fpc-pascal wrote: >> But the 'current translation' is simply the value of the >> resourcestring, so >> you should not need to look it up ? > > How? > > I'm trying to detect this specific exception > >       raise EInvalidOperation.Create(sCannotFocus); > > (where sCannotFocus is defined in LCLStrConsts). > > I tried > >   if E is EInvalidOperation then >      if E.message=sCannotFocus > > but it doesn't work (sCannotFocus holds the original, not the > translated, string). Seems like Lazarus is not using the regular resourcestrings then, because the whole point of using resourcestrings is that their value is the translated value...

Never mind, I was fooled by the debugger tool-tip, which shows the original definition and not the current value of the resourcestring :-(

Bye

Luca

Reply by email

Mattias Gaertner
to Michael Van Canneyt: Seems like Lazarus is not using the regular resourcestrings then, because the whole point…

On Wed, 2 Dec 2020 13:30:13 +0100 (CET)
Michael Van Canneyt via fpc-pascal

Show quoted text 9 lines
On Wed, 2 Dec 2020, Luca Olivetti via fpc-pascal wrote: [...] > but it doesn't work (sCannotFocus holds the original, not the > translated, string). Seems like Lazarus is not using the regular resourcestrings then, because the whole point of using resourcestrings is that their value is the translated value...

Sounds like a conspiracy theory.

What about the simple explanation, that there are two resourcestrings with the same name in RTLConsts and LCLStrConsts and Luca is looking at the wrong one?

See Hanlon's razor.

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 15 lines
On Wed, 2 Dec 2020 13:30:13 +0100 (CET) Michael Van Canneyt via fpc-pascal wrote: > On Wed, 2 Dec 2020, Luca Olivetti via fpc-pascal wrote: > > [...] > > but it doesn't work (sCannotFocus holds the original, not the > > translated, string). > > Seems like Lazarus is not using the regular resourcestrings then, > because the whole point of using resourcestrings is that their value > is the translated value... Sounds like a conspiracy theory.

Just trying to go with the times ;-)

What about the simple explanation, that there are two resourcestrings with the same name in RTLConsts and LCLStrConsts and Luca is looking at the wrong one?

Also an option. :-)
The question is then why there are 2 copies of a string ? :-)

See Hanlon's razor.

What's wrong with Occam's razor ? Too old ?

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt

On Wed, 2 Dec 2020 13:48:35 +0100 (CET)
Michael Van Canneyt via fpc-pascal

Show quoted text 8 lines
On Wed, 2 Dec 2020, Mattias Gaertner via fpc-pascal wrote: [...] > What about the simple explanation, that there are two > resourcestrings with the same name in RTLConsts and LCLStrConsts and > Luca is looking at the wrong one? Also an option. :-) The question is then why there are 2 copies of a string ? :-)

That's the stupidity.

> See Hanlon's razor. What's wrong with Occam's razor ? Too old ?

Occam is about most simple. Hanlon specifies that stupidity is more simple than malice.

Mattias

Reply by email