3
# ***** BEGIN GPL LICENSE BLOCK *****
5
# This program is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU General Public License
7
# as published by the Free Software Foundation; either version 2
8
# of the License, or (at your option) any later version.
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.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software Foundation,
17
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
# ***** END GPL LICENSE BLOCK *****
23
# Update po’s in the branches from blender.pot in /trunk/po dir.
25
import concurrent.futures
28
from codecs import open
35
from . import (settings, utils)
38
GETTEXT_MSGMERGE_EXECUTABLE = settings.GETTEXT_MSGMERGE_EXECUTABLE
39
BRANCHES_DIR = settings.BRANCHES_DIR
40
TRUNK_PO_DIR = settings.TRUNK_PO_DIR
41
FILE_NAME_POT = settings.FILE_NAME_POT
45
po, lang, pot_msgs = data
47
msg = utils.I18nMessages(iso=lang, kind='PO', src=po)
48
print("Updating {}...".format(po))
50
msg.write(kind='PO', dest=po)
51
print("Finished updating {}!\n".format(po))
57
parser = argparse.ArgumentParser(description="Write out messages.txt from Blender.")
58
parser.add_argument('-t', '--trunk', action="store_true", help="Update po’s in /trunk/po rather than /branches.")
59
parser.add_argument('-i', '--input', metavar="File", help="Input pot file path.")
60
parser.add_argument('-a', '--add', action="store_true",
61
help="Add missing po’s (useful only when one or more languages are given!).")
62
parser.add_argument('langs', metavar='ISO_code', nargs='*', help="Restrict processed languages to those.")
63
args = parser.parse_args()
67
FILE_NAME_POT = args.input
70
pot_msgs = utils.I18nMessages(kind='PO', src=FILE_NAME_POT)
74
for lang in args.langs:
77
po = os.path.join(dr, ".".join((lang, "po")))
79
dr = os.path.join(BRANCHES_DIR, lang)
80
po = os.path.join(dr, ".".join((lang, "po")))
82
if not os.path.exists(dr):
84
if not os.path.exists(po):
85
shutil.copy(FILE_NAME_POT, po)
86
if args.add or os.path.exists(po):
87
pool_data.append((po, lang, pot_msgs))
89
for po in os.listdir(TRUNK_PO_DIR):
90
if po.endswith(".po"):
91
lang = os.path.basename(po)[:-3]
92
po = os.path.join(TRUNK_PO_DIR, po)
93
pool_data.append((po, lang, pot_msgs))
95
for lang in os.listdir(BRANCHES_DIR):
96
po = os.path.join(BRANCHES_DIR, lang, ".".join((lang, "po")))
97
if os.path.exists(po):
98
pool_data.append((po, lang, pot_msgs))
100
for r in map(process_po, pool_data):
103
#with concurrent.futures.ProcessPoolExecutor() as executor:
104
#for r in executor.map(process_po, pool_data, timeout=600):
111
if __name__ == "__main__":
112
print("\n\n *** Running {} *** \n".format(__file__))
b'\\ No newline at end of file'