]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - locale/translate.sh
another gettext() patch from Jan (fix plus translation of savepage)
[SourceForge/phpwiki.git] / locale / translate.sh
1 #!/bin/bash
2 # translate.sh
3 #
4 # Usage:
5 #
6 #   ./locale/translate.sh
7 #
8 # This script should be run by
9 #
10 #    * PphWiki maintainers, before making a distribution
11 #    * Translators, after making a translation update
12 #
13
14 if [ ! -f index.php ]; then
15         echo Usage: ./locale/translate.sh
16         exit 2
17 fi
18
19 ALL_LINGUAS=nl
20
21 xgettext -L C++ -o locale/po/phpwiki.pot lib/*php
22 podir=locale/po
23 for i in $ALL_LINGUAS; do
24         po=$podir/$i.po
25         pot=$podir/phpwiki.pot
26         locale=locale/$i/LC_MESSAGES
27
28         msgmerge -o $po $po $pot
29         mkdir -p $locale
30         msgfmt -o $locale/phpwiki.mo $po
31
32         awk -- '
33 BEGIN {
34   msgid=""; msgstr="";
35   print ("<?php\n");
36 }
37 /^msgid ""/ {
38   if (msgid && str)
39     print ("$locale[\"" msgid "\"] =\n   \"" str "\";");
40   str="";
41   next;
42 }
43 /^msgid "/ { #"{
44   if (msgid && str)
45     print ("$locale[\"" msgid "\"] =\n   \"" str "\";");
46   str = substr ($0, 8, length ($0) - 8);
47   msgstr="";
48 }
49 /^msgstr ""/ {
50   msgid=str;
51   str="";
52   next;
53 }
54 /^msgstr "/ { #"{
55   msgid=str;
56   str = substr ($0, 9, length ($0) - 9);
57   next;
58 }
59 /^"/ { #"{
60   str = (str substr ($0, 2, length ($0) - 2));
61   next;
62 }
63 END {
64   if (mgsid && str)
65     print ("$locale[\"" msgid "\"] =\n   \"" str "\";");
66   print ("\n;?>");
67 }
68
69 ' $po > $locale/phpwiki.php
70 done