[libvirt] [PATCH 1/2] virsh: use more compact VIR_ENUM_IMPL
Michal Privoznik
mprivozn at redhat.com
Mon Feb 24 17:54:47 UTC 2014
On 24.02.2014 18:49, Eric Blake wrote:
> On 02/24/2014 10:42 AM, Michal Privoznik wrote:
>
>>>
>>> +VIR_ENUM_DECL(vshDomainIOError)
>>> +VIR_ENUM_IMPL(vshDomainIOError,
>>> + VIR_DOMAIN_DISK_ERROR_LAST,
>>> + N_("no error"),
>>> + N_("unspecified error"),
>>> + N_("no space"))
>>> +
>
>>> - return _("unknown error");
>>> + const char *str = vshDomainIOErrorTypeToString(error);
>>> + return str ? _(str) : _("unknown error");
>>> }
>>>
>>
>> Why _(str) if str itself already contains translated message?
>
> str is NOT translated. C semantics forbid initializing something with a
> function call, and VIR_ENUM_IMPL is creating an initializer. N_() is a
> markup that is a no-op to the C compiler (so you aren't violating
> initializer rules) while still marking a string for translation for the
> purposes of xgettext scanning; we still have to actually translate the
> string at some point down the road. Hence, my call to _(str) - where we
> are translating a string, but where xgettext sees that it is a variable
> rather than a string literal and so has nothing it can stick in the .po
> file. You need both halves for translating strings that are stored in
> an initializer list.
>
I see. ACK then.
Michal
More information about the libvir-list
mailing list