1# 2# aegis - project change supervisor 3# Copyright (C) 2004, 2006-2008 Peter Miller 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see 17# <http://www.gnu.org/licenses/>. 18# 19# This awk script munges the POT file into something that the 20# Translation Project's tools can cope with. Aparrently it isn't enough 21# that the file is in a correct format, it has to be in the default 22# (empty msgstr) format coming out of xgettext, and unindented, too. 23# 24# The English translation is thus shifted into the leading comment for 25# translator's reference. 26# 27# The leading header comment is also mangled to add the "optional" 28# Project-Id-Version and POT-Creation-Date lines which their system 29# can't seem to cope without. 30# 31function process() 32{ 33 if (msgid_value != "") 34 { 35 if (msgid_value == "msgid \"\"") 36 { 37 print msgid_value 38 print msgstr_value 39 vers = ENVIRON["VERSION"] 40 if (vers != "") 41 print "\"Project-Id-Version: aegis " vers "\\n\"" 42 print "\"POT-Creation-Date: " strftime() "\\n\"" 43 } 44 else 45 { 46 print "# For consistent translation, here is the English text:" 47 print hash_msgstr_value 48 print "# Please translate the English msgstr, not the msgid." 49 print msgid_value 50 print "msgstr \"\"" 51 } 52 } 53 msgid = 0 54 msgid_value = "" 55 msgstr = 0 56 msgstr_value = "" 57 hash_msgstr_value = "" 58} 59 60/^msgid/ { 61 msgid = 1 62 msgid_value = $0 63 next 64} 65/^msgstr/ { 66 msgid = 0 67 msgstr = 1 68 msgstr_value = $0 69 hash_msgstr_value = "# " $0 70 next 71} 72/^[ ]*".*"$/ { 73 if (msgid) 74 msgid_value = msgid_value "\n" $0 75 if (msgstr) 76 { 77 msgstr_value = msgstr_value "\n" $0 78 hash_msgstr_value = hash_msgstr_value "\n# " $0 79 } 80 next 81} 82/^[ ]*$/ { 83 process() 84 print 85 next 86} 87{ 88 print 89} 90END { 91 process() 92} 93