Hi,

Jonas Meurer wrote (01 Jun 2010 19:38:01 GMT) :
> feel free to provide a patch. i don't have the time right now to do
> the migration.

please find, attached, a patch that adds gettext support to the
luksformat script.

I've not patched the packaging yet => left to do:

- provide a way to more or less automatically extract the translatable
  strings, update existing PO files, compile PO files to MO;
- binary package(s) that ship the luksformat script must have a
  "Depends: liblocale-gettext-perl".

Bye,
--
  intrigeri <intrig...@boum.org>
  | GnuPG key @ https://gaffer.ptitcanardnoir.org/intrigeri/intrigeri.asc
  | OTR fingerprint @ 
https://gaffer.ptitcanardnoir.org/intrigeri/otr-fingerprint.asc
  | Did you exchange a walk on part in the war
  | for a lead role in the cage?

--- luksformat.orig	2010-10-06 23:35:22.233053150 +0200
+++ luksformat	2010-10-07 00:21:04.950223269 +0200
@@ -9,10 +9,17 @@
 # (http://www.gnu.org/copyleft/gpl.html)
 
 use Getopt::Long qw(:config pass_through);
+use Locale::gettext;
+use POSIX;
+
+# gettext initialization
+setlocale(LC_MESSAGES, "");
+textdomain("luksformat");
 
 sub help() {
-    print "luksformat - Create and format an encrypted LUKS device
-Usage: luksformat [-t <file system>] <device> [ mkfs options ]\n";
+    print gettext("luksformat - Create and format an encrypted LUKS device"),
+          gettext("Usage: luksformat [-t <file system>] <device> [ mkfs options ]"),
+          "\n";
     exit 1;
 }
 
@@ -23,7 +30,7 @@
 help() if $#ARGV < 0;
 
 if ($> != 0) {
-    print STDERR "This program needs to be started as root\n";
+    print STDERR gettext("This program needs to be started as root"), "\n";
     exit 1;
 }
 
@@ -31,7 +38,7 @@
 
 open(MOUNTS, "/proc/mounts");
 while (<MOUNTS>) {
-    die "Error: device mounted: $device\n" if (/\Q$device\E/)
+    die sprintf(gettext("Error: device mounted: %s"), $device), "\n" if (/\Q$device\E/)
 }
 
 if (-x "/sbin/mkfs.$fs") {
@@ -41,7 +48,7 @@
     $mkfs = "/usr/sbin/mkfs.$fs";
 }
 else {
-    print STDERR "Error: invalid file system: $fs\n";
+    print STDERR sprintf(gettext("Error: invalid file system: %s"), "$fs"), "\n";
     exit 1;
 }
 
@@ -54,18 +61,18 @@
     }
 }
 
-$name or die "Error: could not generate temporary mapped device name";
+$name or die gettext("Error: could not generate temporary mapped device name");
 
 # we do not need to be overly concerned with race conditions here, cryptsetup
 # will just fail if the name already exists now.
-print "Creating encrypted device on $device...\n";
+print sprintf(gettext("Creating encrypted device on %s..."), $device), "\n";
 if ((system 'cryptsetup', 'luksFormat', '-s', '256', '--cipher', 'aes-cbc-essiv:sha256', $device)) {
-    die "Could not create LUKS device $device";
+    die sprintf(gettext("Could not create LUKS device %s"), $device);
 }
 
-print "Please enter your passphrase again to verify it\n";
+print gettext("Please enter your passphrase again to verify it"), "\n";
 if ((system 'cryptsetup', 'luksOpen', $device, $name) != 0) {
-    print STDERR "The passphrases you entered were not identical\n";
+    print STDERR gettext("The passphrases you entered were not identical"), "\n";
     exit 1;
 }
 
@@ -73,7 +80,7 @@
 print "\n";
 system 'cryptsetup', 'luksClose', $name;
 
-die "Could not format device with file system $fs" if $result;
+die sprintf(gettext("Could not format device with file system %s"), $fs) if $result;
 
 __END__
 

Reply via email to