r510 - trunk/misc

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Feb 26 23:04:47 EST 2008


Author: icculus
Date: 2008-02-26 23:04:47 -0500 (Tue, 26 Feb 2008)
New Revision: 510

Added:
   trunk/misc/localization2pot.pl
Log:
Initial add.


Added: trunk/misc/localization2pot.pl
===================================================================
--- trunk/misc/localization2pot.pl	                        (rev 0)
+++ trunk/misc/localization2pot.pl	2008-02-27 04:04:47 UTC (rev 510)
@@ -0,0 +1,75 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+use Encode qw( decode_utf8 );
+
+# Fixes unicode dumping to stdio...hopefully you have a utf-8 terminal by now.
+binmode(STDIN, ":utf8");
+binmode(STDOUT, ":utf8");
+binmode(STDERR, ":utf8");
+
+print <<__EOF__;
+
+# MojoSetup; a portable, flexible installation application.
+#
+# Please see the file LICENSE.txt in the source's root directory.
+#
+# This file generated by localization2pot.pl
+#
+#
+# NOTE: If you care about Unicode or ASCII chars above 127, this file _MUST_
+#  be UTF-8 encoded! If you think you're using a certain high-ascii codepage,
+#  you're wrong!
+#
+# Whenever you see a %x sequence, that is replaced with a string at runtime.
+#  So if you see, "Hello, %0, my name is %1.", then this might become
+#  "Hello, Alice, my name is Bob." at runtime. If your culture would find
+#  introducing yourself second to be rude, you might translate this to:
+#  "My name is %1, hello %0." If you need a literal '%' char, write "%%":
+#  "Operation is %0%% complete" might give "Operation is 3% complete."
+#  All strings, from your locale or otherwise, are checked for formatter
+#  correctness at startup. This is to prevent the installer working fine
+#  in all reasonable tests, then finding out that one guy in Ghana has a
+#  crashing installer because his localization forgot to add a %1 somewhere.
+#
+# Occasionally you might see a "\\n" ... that's a newline character. "\\t" is
+#  a tab character, and "\\\\" turns into a single "\\" character.
+#
+# Questions about the intent of a specific string can go to Ryan C. Gordon
+#  (icculus\@icculus.org).
+
+__EOF__
+
+
+while (<STDIN>) { last if (/MojoSetup.localization = {/); }
+
+my $looking_for_end = 0;
+
+while (<STDIN>) {
+    chomp;
+    s/\A\s+//;
+    s/\s+\Z//;
+    next if ($_ eq '');
+    if (/\A};\Z/) {
+        last if (not $looking_for_end);
+        $looking_for_end = 0;
+        next;
+    } else {
+        next if $looking_for_end;
+    }
+
+    if (s/\A\[(\".*?\")\] = {\Z/msgid $1\nmsgstr ""\n/) {
+        print("$_\n");
+        $looking_for_end = 1;
+    } elsif (s/\A--\s+(.*?)\Z/#. $1/) {
+        print("$_\n");
+    } else {
+        die("unhandled string: '$_'\n");
+    }
+}
+
+print "# end of localization.pot ...\n\n";
+
+# end of localization2pot.pl ...
+


Property changes on: trunk/misc/localization2pot.pl
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native




More information about the mojosetup-commits mailing list