- translation scripts now run with py3.x

- added convenience make target 'make translations'
- some MEM_malloc strings were not unique enough, expanded them.
This commit is contained in:
2011-09-20 17:07:33 +00:00
parent 9d1b4b63b3
commit 8cf8fd7326
9 changed files with 187 additions and 67 deletions

View File

@@ -130,6 +130,10 @@ help:
@echo " * package_pacman - build an arch linux pacmanpackage"
@echo " * package_archive - build an archive package"
@echo ""
@echo "Other Targets"
@echo " * translations - update blenders translation files in po/"
# TODO, doxygen and sphinx docs
@echo ""
@echo "Testing Targets (not assosiated with building blender)"
@echo " * test - run ctest, currently tests import/export, operator execution and that python modules load"
@echo " * test_cmake - runs our own cmake file checker which detects errors in the cmake file list definitions"
@@ -156,6 +160,15 @@ package_archive:
@echo archive in "$(BUILD_DIR)/release"
# -----------------------------------------------------------------------------
# Other Targets
#
translations:
python3 po/update_pot.py
python3 po/update_po.py
python3 po/update_mo.py
# -----------------------------------------------------------------------------
# Tests
#

View File

@@ -1,17 +1,53 @@
#!/usr/bin/python
#!/usr/bin/env python
# $Id:
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
# <pep8 compliant>
# update all mo files in the LANGS
import subprocess
import os
LOCALE_DIR="../release/bin/.blender/locale"
PO_DIR = "."
CURRENT_DIR = os.path.dirname(__file__)
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.join(CURRENT_DIR, "..")))
LOCALE_DIR = os.path.join(SOURCE_DIR, "release", "bin", ".blender", "locale")
DOMAIN = "blender"
for po in os.listdir( PO_DIR ):
def main():
for po in os.listdir(CURRENT_DIR):
if po.endswith(".po"):
lang = po[:-3]
# show stats
cmd = "msgfmt --statistics %s.po -o %s/%s/LC_MESSAGES/%s.mo" % ( lang, LOCALE_DIR, lang, DOMAIN )
print cmd
os.system( cmd )
cmd = ("msgfmt",
"--statistics",
os.path.join(CURRENT_DIR, "%s.po" % lang),
"-o",
os.path.join(LOCALE_DIR, lang, "LC_MESSAGES", "%s.mo" % DOMAIN),
)
print(" ".join(cmd))
process = subprocess.Popen(cmd)
process.wait()
if __name__ == "__main__":
main()

View File

@@ -1,17 +1,52 @@
#!/usr/bin/python
#!/usr/bin/env python
# $Id:
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
# <pep8 compliant>
# update all po files in the LANGS
import subprocess
import os
PO_DIR = "."
CURRENT_DIR = os.path.dirname(__file__)
DOMAIN = "blender"
for po in os.listdir( PO_DIR ):
def main():
for po in os.listdir(CURRENT_DIR):
if po.endswith(".po"):
lang = po[:-3]
# update po file
cmd = "msgmerge --update --lang=%s %s.po %s.pot" % (lang, lang, DOMAIN)
print(cmd)
os.system( cmd )
# update po file
cmd = ("msgmerge",
"--update",
"--lang=%s" % lang,
os.path.join(CURRENT_DIR, "%s.po" % lang),
os.path.join(CURRENT_DIR, "%s.pot" % DOMAIN),
)
print(" ".join(cmd))
process = subprocess.Popen(cmd)
process.wait()
if __name__ == "__main__":
main()

View File

@@ -1,31 +1,61 @@
#!/usr/bin/python
#!/usr/bin/env python
# $Id:
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
# <pep8 compliant>
# update the pot file according the POTFILES.in
import subprocess
import os
GETTEXT_XGETTEXT_EXECUTABLE = "xgettext"
SOURCE_DIR=".."
CURRENT_DIR = os.path.dirname(__file__)
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.join(CURRENT_DIR, "..")))
DOMAIN = "blender"
cmd = "%s --files-from=%s/po/POTFILES.in --keyword=_ --keyword=N_ --directory=%s --output=%s/po/%s.pot --from-code=utf-8" % (
GETTEXT_XGETTEXT_EXECUTABLE, SOURCE_DIR, SOURCE_DIR, SOURCE_DIR, DOMAIN)
FILE_NAME_POT = os.path.join(CURRENT_DIR, "blender.pot")
FILE_NAME_MESSAGES = os.path.join(CURRENT_DIR, "messages.txt")
os.system( cmd )
def main():
cmd = (GETTEXT_XGETTEXT_EXECUTABLE,
"--files-from=%s" % os.path.join(SOURCE_DIR, "po", "POTFILES.in"),
"--keyword=_",
"--keyword=N_",
"--directory=%s" % SOURCE_DIR,
"--output=%s" % os.path.join(SOURCE_DIR, "po", "%s.pot" % DOMAIN),
"--from-code=utf-8",
)
print(" ".join(cmd))
process = subprocess.Popen(cmd)
process.wait()
def stripeol(s):
if line.endswith("\n"):
s = s[:-1]
if line.endswith("\r"):
s = s[:-1]
return s
return s.rstrip("\n\r")
pot_messages = {}
reading_message = False
message = ""
with open("blender.pot", 'r') as handle:
with open(FILE_NAME_POT, 'r') as handle:
while True:
line = handle.readline()
@@ -43,8 +73,8 @@ with open("blender.pot", 'r') as handle:
message += line[1:-1]
# add messages collected automatically from RNA
with open("blender.pot", "a") as pot_handle:
with open("messages.txt", 'r') as handle:
with open(FILE_NAME_POT, "a") as pot_handle:
with open(FILE_NAME_MESSAGES, 'r') as handle:
while True:
line = handle.readline()
@@ -59,3 +89,7 @@ with open("blender.pot", "a") as pot_handle:
pot_handle.write("\n#: Automatically collected from RNA\n")
pot_handle.write("msgid \"%s\"\n" % (line))
pot_handle.write("msgstr \"\"\n")
if __name__ == "__main__":
main()

View File

@@ -2935,7 +2935,7 @@ void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
dm->getMinMax(dm, min, max);
if(!ob->bb)
ob->bb= MEM_callocN(sizeof(BoundBox), "bb");
ob->bb= MEM_callocN(sizeof(BoundBox), "DM-BoundBox");
boundbox_set_from_min_max(ob->bb, min, max);
}

View File

@@ -2350,7 +2350,7 @@ BoundBox *unit_boundbox(void)
BoundBox *bb;
float min[3] = {-1.0f,-1.0f,-1.0f}, max[3] = {-1.0f,-1.0f,-1.0f};
bb= MEM_callocN(sizeof(BoundBox), "bb");
bb= MEM_callocN(sizeof(BoundBox), "OB-BoundBox");
boundbox_set_from_min_max(bb, min, max);
return bb;

View File

@@ -12224,7 +12224,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
BlendFileData *bfd;
bfd= MEM_callocN(sizeof(BlendFileData), "blendfiledata");
bfd->main= MEM_callocN(sizeof(Main), "main");
bfd->main= MEM_callocN(sizeof(Main), "readfile_Main");
BLI_addtail(&fd->mainlist, bfd->main);
bfd->main->versionfile= fd->fileversion;

View File

@@ -87,6 +87,8 @@ void BPY_atexit_register(void)
void BPY_atexit_unregister(void)
{
BLI_assert(func_bpy_atregister != NULL);
atexit_func_call("unregister", func_bpy_atregister);
func_bpy_atregister= NULL; /* don't really need to set but just incase */
}

View File

@@ -85,7 +85,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
void wm_event_add(wmWindow *win, wmEvent *event_to_add)
{
wmEvent *event= MEM_callocN(sizeof(wmEvent), "event");
wmEvent *event= MEM_callocN(sizeof(wmEvent), "wmEvent");
*event= *event_to_add;
BLI_addtail(&win->queue, event);