system: Linux mars.sprixweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
cmd: 

Direktori : /usr/local/src/xcache-3.2.0/devel/
Upload File :
Current File : //usr/local/src/xcache-3.2.0/devel/po2php.awk

#!/usr/bin/awk -f
BEGIN {
	print "<?php";
	print "// auto generated, do not modify";
	print "$strings += array(";
}

function flushOut() {
	if (section) {
		if (section == "msgstr") {
			if (msgid == "") {
			}
			else if (msgstr == "") {
			}
			else {
				print "\t\t\""msgid"\"";
				print "\t\t=> \""msgstr"\",";
			}
		}
		else {
			print "unexpected section " section;
			exit 1;
		}
		section = null;
	}
}

/^msgid ".*"$/ {
	$0 = gensub(/^msgid "(.*)"$/, "\\1", $0);

	section = "msgid";
	msgid = $0;
	next;
}
/^msgstr ".*"$/ {
	$0 = gensub(/^msgstr "(.*)"$/, "\\1", $0);

	section = "msgstr";
	msgstr = $0;
	next;
}
/^".*"$/ {
	$0 = gensub(/^"(.*)"$/, "\\1", $0);
	if (section == "msgid") {
		msgid = msgid $0;
	}
	else {
		msgstr = msgstr $0;
	}
	next;
}
/^$/ {
	flushOut();
	next;
}
/^#/ {
	next;
}
/./ {
	print "error", $0;
	exit 1;
}
END {
	flushOut();
	print "\t\t);";
	print "";
}