Debian Codegraph @

extras/en_po.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 #
3 # QBrz - Qt frontend to Breezy commands
4 # Copyright (C) 2010 Alexander Belchenko <[email protected]>
5 #
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.
10 #
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.
15 #
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
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 """Regenerate English en.po file from POT file."""
21
22 import os
23
24
25 def regenerate_en(prj_name, po_dir, pot_file, spawn):
26 if prj_name and prj_name != 'messages':
27 en_po = '%s-en.po' % prj_name
28 else:
29 en_po = 'en.po'
30 en_po_path = os.path.join(po_dir, en_po)
31 spawn(['msginit', '--no-translator', '-l', 'en', '-i', os.path.join(po_dir, pot_file), '-o', en_po_path, ])
32 # normalize line-endings in en.po file (to LF)
33 f = open(en_po_path, 'rU')
34 s = f.read()
35 f.close()
36 f = open(en_po_path, 'wb')
37 f.write(s)
38 f.close()