4 # ***** BEGIN GPL LICENSE BLOCK *****
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # ***** END GPL LICENSE BLOCK *****
24 # update the pot file according the POTFILES.in
28 from codecs import open
30 CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
32 FILE_NAME_POT = os.path.join(CURRENT_DIR, "blender.pot")
35 def read_messages(fname):
37 return s.rstrip("\n\r")
40 reading_message = False
42 with open(fname, 'r', "utf-8") as handle:
44 line = handle.readline()
50 if line.startswith("msgid"):
51 reading_message = True
53 elif line.startswith("msgstr"):
54 reading_message = False
55 messages[message] = True
62 pot_messages = read_messages(FILE_NAME_POT)
65 for lang in sys.argv[1:]:
66 po = os.path.join(CURRENT_DIR, lang + '.po')
68 if os.path.exists(po):
69 po_messages = read_messages(po)
70 for msgid in po_messages:
71 if not pot_messages.get(msgid):
72 print('Unneeded message id \'%s\'' % (msgid))
74 for msgid in pot_messages:
75 if not po_messages.get(msgid):
76 print('Missed message id \'%s\'' % (msgid))
78 for po in os.listdir(CURRENT_DIR):
79 if po.endswith('.po'):
80 print('Processing %s...' % (po))
81 po_messages = read_messages(po)
82 for msgid in po_messages:
83 if not pot_messages.get(msgid):
84 print(' Unneeded message id \'%s\'' % (msgid))
86 for msgid in pot_messages:
87 if not po_messages.get(msgid):
88 print(' Missed message id \'%s\'' % (msgid))
91 if __name__ == "__main__":
92 print("\n\n *** Running %r *** \n" % __file__)