summaryrefslogtreecommitdiff
path: root/bin/add_text
diff options
context:
space:
mode:
Diffstat (limited to 'bin/add_text')
-rwxr-xr-xbin/add_text54
1 files changed, 54 insertions, 0 deletions
diff --git a/bin/add_text b/bin/add_text
new file mode 100755
index 0000000..61857c7
--- /dev/null
+++ b/bin/add_text
@@ -0,0 +1,54 @@
+#! /usr/bin/perl
+
+# add a new text to *.po files
+
+die "usage: add_text [-c comment] id text_line1 text_line2 ... \nexample:\n add_text MENU_LANG Language\n" if @ARGV < 2;
+
+if($ARGV[0] eq '-c') {
+ shift;
+ $comment = shift;
+}
+
+$id = shift;
+@texts = @ARGV;
+
+$id =~ s/^TXT_//;
+
+$_ = join '', @texts;
+
+push @l, "# $comment\n" if $comment;
+push @l, "#. TXT_$id\n";
+push @l, "#, c-format\n" if /%/;
+
+if(@texts == 1) {
+ push @l, "msgid \"$texts[0]\"\n"
+}
+else {
+ push @l, "msgid \"\"\n";
+ for (@texts) { push @l, "\"$_\"\n" }
+}
+
+push @l, "msgstr \"\"\n";
+push @l, "\n";
+
+print @l;
+
+print STDERR "Should this entry be added to all *.po files? [Y/n]\n";
+
+$_ = <STDIN>;
+
+chomp;
+
+$_ = "\L$_";
+
+exit unless $_ eq '' || $_ eq 'y';
+
+print "ok\n";
+
+for $f ("linuxrc.pot", <*.po>) {
+ if(open F, ">>$f") {
+ print F @l;
+ close F;
+ }
+}
+