Re: [PATCH 1/2] virsh: use more compact VIR_ENUM_IMPL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]