This patch makes Perl strings translatable. The Perl strings end up
in the PO files as usual. It does not touch the embedded POD.
Internationalizing the Perl strings was pleasantly simple. Just add:
use Locale::TextDomain 'libguestfs';
at the top of any *.pl or *.pm file. Then for each string in the file
that you want to be translatable you place TWO underscores before it:
- die "virt-inspector: no YAML support\n"
+ die __"virt-inspector: no YAML support\n"
unless exists $INC{"YAML/Any.pm"};
However this doesn't work if the string contains any $substitutions.
In that case you have to use the __x (two underscores and x) operator:
- die "guest image $_ does not exist or is not readable"
+ die __x("guest image {imagename} does not exist or is not readable",
+ imagename => $_)
unless -r $_;
The second case causes a note to be added to the PO file, so hopefully
the translators will understand not to change the placeholders inside
braces:
+#: perl/blib/lib/Sys/Guestfs/Lib.pm:142 perl/lib/Sys/Guestfs/Lib.pm:142
+#, perl-brace-format
+msgid "guest image {imagename} does not exist or is not readable"
+msgstr ""
The patch is otherwise fairly simple. I've changed po/POTFILES.in so
that it is now generated automatically, and it includes the daemon
code which we don't translate yet, but might consider doing in future.
'perl-libintl' is now a required module for virt-df / virt-inspector /
virt-v2v (but not for the basic Perl bindings).
This FAQ is useful to explain some of the reasons for the changes
above:
http://search.cpan.org/dist/libintl-perl/lib/Locale/libintlFAQ.pod
Rich.
--
Richard Jones, Emerging Technologies, Red Hat
http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/