diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-09 00:44:48 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-09 00:44:48 +0400 |
commit | ac6d91b9396c15d8bf1aa550adb4ca8c7125dd81 (patch) | |
tree | 88d1f046c6548331fdb705f91fcc63b8595f9f03 /intern/locale/SConscript | |
parent | 0d1a49936627f2885b058f23920490bc6ed7c282 (diff) |
Be ready for changes in bf-translations repository
Made it so if there's release/datafiles/locale/po
folder, then all the .po files will be converted
to .mo at blender compile time and installed to
an appropriate location.
Uses small own implementation msgfmt which is
based on msgfmt.py from Python project, but also
supports contexts.
There's no functional changes for until we've
switched to use source .po files instead of
pre-compiled .mo.
P.S. Well, there's one change which is msgfmt.cc
being compiled even if it's not used, but
would rather not clutter code with checks
since pretty soon we'll use this program
anyway.
Diffstat (limited to 'intern/locale/SConscript')
-rw-r--r-- | intern/locale/SConscript | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/intern/locale/SConscript b/intern/locale/SConscript index f60bd90fb38..546fd3e8b40 100644 --- a/intern/locale/SConscript +++ b/intern/locale/SConscript @@ -37,3 +37,49 @@ if env['WITH_BF_INTERNATIONAL']: incs += ' ' + env['BF_BOOST_INC'] env.BlenderLib( 'bf_intern_locale', sources, Split(incs), defs, libtype=['intern','player'], priority=[10, 185]) + +if env['WITH_BF_INTERNATIONAL']: + import os + from os.path import dirname + + def normpath(path): + return os.path.abspath(os.path.normpath(path)) + + # build directory + source_dir = Dir('.').srcnode().path + root_build_dir = normpath(env['BF_BUILDDIR']) + root_source_dir = dirname(dirname(normpath(source_dir))) + po_dir = os.path.join(root_source_dir, "release", "datafiles", "locale", "po") + build_dir = os.path.join(root_build_dir, 'locale') + + if os.path.exists(po_dir): + # create directory if needed + if not os.path.exists(build_dir): + os.makedirs(build_dir) + + msgfmt_tool = env.Clone() + targetpath = root_build_dir + '/msgfmt' + msgfmt_target = msgfmt_tool.Program(target = targetpath, source = ['msgfmt.cc']) + + locale = env.Clone() + + # dependencies + dependencies = [targetpath] + + # add command for each locale + all_mo_files = [] + for f in os.listdir(po_dir): + if not f.endswith(".po"): + continue + + po_file = os.path.join(po_dir, f) + mo_file = os.path.join(build_dir, os.path.splitext(f)[0] + ".mo") + + command = "\"%s\" \"%s\" \"%s\"" % (targetpath, po_file, mo_file) + + locale.Command(mo_file, po_file, command) + locale.Depends(mo_file, dependencies) + + all_mo_files.append(mo_file) + + env.Depends("boost_locale_wrapper.cpp", all_mo_files) |