Next: Save the translation template, Previous: Mark strings for internationalization, Up: Pure Scheme internationalization with po-lib [Contents][Index]
With the previous example, you may extract the translations:
(import (po-lib)) (define (main) "Say the line." (display (gettext "Hello, world!")) (newline)) (dynamic-xgettext #f "myproject" "0.0" "msgid-bugs@myproject" main)
What this will do is return a list of template translations, starting
with a header with all the information, and then all translations that
were used when calling main with no argument.
Return multiple values: a list of template translations with a header first, and all values returned by f called with no arguments.
The extraction is dynamic, because strings within dead code will not be detected. It may be difficult to exercise all the translations in a complex program however.
Prematurely register all the occurences of calls to gettext or
mark-string and then expand code in the same lexical
scope. Even the messages in deep rarely used code branches will thus
be marked for translations, provided the lexical scope of the
expansion of with-marked-strings is reached during the
dynamic-xgettext invocation.
For instance,
(dynamic-xgettext #f "example" "0.0.0" "test@example.org"
(lambda ()
(when #f
(display (gettext "Oh no, a rare condition occured!")))))
will return a translation with only the header template, because the useful branch is never reached, while
(dynamic-xgettext #f "example" "0.0.0" "test@example.org"
(lambda ()
(with-marked-strings #f
(when #f
(display (gettext "Oh no, a rare condition occured!"))))))
will return 2 translations templates: the header template, and the message “Oh no, a rare condition occured!”.