[fpc-pascal] Re: Get all caller adresses of a given
function/procedure before executing
Marco van de Voort
marcov at stack.nl
Mon Aug 13 12:29:51 CEST 2012
In our previous episode, Lukasz Sokol said:
> Me neither - but IIRC using gettext (dxgettext) was something /incredibly/ easy :
> the translating function is called '_()' :) (yes, function _([const] input: string): string; )
> (allegedly, in newer (dx)gettext, not even that- it's enough to have (dx)gettext unit included,
> but don't quote me on this one).
Afaik the dxgettext patched for D2009+
For resourcestrings yes, but using resourcestrings in structured constants
and afaik also (D2010+) custom RTTI need updating manually. (while they
don't with Delphi's own ITE)
> Then the dxgettext handling program creates the strings to be translated
> list out of that (saves to text .po file), together with programmatic
> context they are used in, as a help for the translator - and then compiles
> to .mo (pls sbdy correct me if I'm wrong) which are loaded at program
> start/on demand/as resourcestrings, (and IIRC may already support
> UTF-8/Unicode/multiple bytes per character strings too - do you)?
Afaik it reads .po's directly, unicode only in D2009+
> The gettext program is out there for (almost) all platforms, AND there are
> plethora of translation-handling programs compatible with it, out there
> too, but you could well enough handle it by editing the po files in any
> decent text editor.
The dxgettext team has an own editor in pure Delphi code called GORM. It has
some features like multiline comments. In the past its main attraction was a
google translate connection, but that has died.
Still if we want an own editor, converting gorm would be an option.
> > I want to knof if the string was called the first time.
> > But since I also get the pchar information of the textsnippets from the
> > programmemory I can translate (make a list or whatever in the future) all
> > snippets before they were called.
> So you don't want to translate it all at the same time, is that what it is?
> Only the strictly necessary portions/snippets as you call them?
Since afaik with gettext, the gettext system is inbetween every lookup, you
could simply maintain a database of looked up strings there.
Since basically there are three levels:
1. sourcecode inspection: in practice also harvest strings from uncompiled code.
2. assembler inspection: in practice also harvests strings from compiled
code that is never executed.
3. runtime detection, mark when a string is accessed: risky since certain
codepaths might only be rarely stressed.
More information about the fpc-pascal