Martin Vermeer wrote:
> On Wed, Sep 17, 2003 at 11:28:36AM +0100, Angus Leeming spake
thusly:
>
>> Martin Vermeer wrote:
>>
>> > On Wed, Sep 17, 2003 at 10:52:48AM +0200, Lars Gullik Bj�nnes
spake
>> > thusly:
>> >
>> >> what happens if you function call replace the default args with
>> >> N_(...)
>> >
>> > ?
>>
>> N_(...) is just an empty macro (does nothing --- see src/gettext.h)
>> that enables the po files to document translatable static strings.
>> See po/Makefile.in.in. The actual call to the gettext translation
is
>> through function _(...)
>>
>> Example:
>>
>> char const * const translated_string =
>> N_("No code to execute. Use N_(...) to flag "
>> "this message for translation");
>>
>> void foo() {
>> string const msg1 = _("Call the gettext translation
service");
>> string const msg2 = _(translated_string);
>> }
>>
>>
>> --
>> Angus
>
> Like this?
No, because this is code executed when the xformsBC constructor is
invoked.
xformsBC(ButtonController const &,
- string const & = _("Cancel"), string const & = _("Close"));
+ string const & = N_("Cancel"), string const & = N_("Close"));
ie
void foo() {
ButtonController const & bc = ...;
xformsBC xbc(bc);
}
will result in calls to the 'string const _(string const &);'
function, passing args "Cancel" and "Close".
To continue. This results in output to screen of 'hello'
string str = _("hello");
void foo() {
std::cout << str << std::endl;
}
For reasons I don't follow, _(...) does not work on static strings.
This will also output 'hello'
string str = "hello";
void foo() {
std::cout << _(str) << std::endl;
}
The scripts that extract the string for translation in the po
database won't find the contents of str.
This, however, will print out 'bonjour' if LANG=fr_FR and a .gmo
file existed
string str = N_("hello");
void foo() {
std::cout << _(str) << std::endl;
}
D'ya follow?
N_(...) is simply an identifier used to extract the translatable
strings by the po scripts. Someone comes along and fills in the
translation. Thereater _("hello") will result in the gettext
machinary finding the translation for "hello" and returning that as
the output from _(...).
Angus