3 Parses .po files and dumps MPSL code.
5 Angel Ortega <angel@triptico.com>
9 sub convert_po_line(line)
11 line = sregex(line, '/^\s*"/');
12 line = sregex(line, '/"$/');
21 sprintf("\\x{%04x}", ord(e)) ||
31 sub parse_po_file(pofile)
36 /* only UTF-8 po files are supported */
39 if ((f = open(pofile, "r")) != NULL) {
45 while ((l = read(f)) != NULL) {
49 local s = regex([ '/^(msgid|msgstr)*/', '/\s*\".*\"$/' ], l);
50 s[1] = convert_po_line(s[1]);
52 if (s[0] eq 'msgid') {
57 if (s[0] eq 'msgstr') {
66 push(r, "/* Built by po2mpsl - Don't modify, change the .po file instead */");
67 push(r, "__I18N__ = {");
71 push(r, "\t\"" ~ join(l[0]) ~ "\" => \"" ~ join(l[1]) ~ "\",");
74 push(r, "\t\"-\" => \"-\"\n};\n");
79 /* back to default encoding */
87 foreach (f, glob('po/*.po')) { /**/
88 local output = parse_po_file(f);
90 /* strip extension and path */
91 f = shift(split(f, '.po'));
92 f = pop(split(f, '/'));
94 local o = open('lang/' ~ f ~ '.mpsl', 'w');