Build and install mo files from po.
authorCarl Hetherington <cth@carlh.net>
Thu, 28 Feb 2013 23:16:13 +0000 (23:16 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 28 Feb 2013 23:16:13 +0000 (23:16 +0000)
i18n.py
src/lib/wscript
src/tools/wscript
src/wscript
src/wx/wscript
wscript

diff --git a/i18n.py b/i18n.py
index c22cbdb95f782f1f79f327a15cb0a8069d48cee6..ab7f6843bea1bfefea357b598c1c4eadbee03cc8 100644 (file)
--- a/i18n.py
+++ b/i18n.py
@@ -17,15 +17,11 @@ def pot(dir, sources, name, all = False):
         os.system('xgettext -d %s -s --keyword=_ --add-comments=/ -p %s -o %s.pot %s' % (name, os.path.join('build', dir), name, s))
     
 
-def po_to_mo(dir, name):
-    for f in glob.glob(os.path.join(dir, 'po', '*.po')):
-        
+def po_to_mo(dir, name, bld):
+    for f in glob.glob(os.path.join(os.getcwd(), dir, 'po', '*.po')):
         lang = os.path.basename(f).replace('.po', '')
-        out = os.path.join('build', dir, 'mo', lang, '%s.mo' % name)
-        try:
-            os.makedirs(os.path.dirname(out))
-        except:
-            pass
+        po = os.path.join('po', '%s.po' % lang)
+        mo = os.path.join('mo', lang, '%s.mo' % name)
 
-        os.system('msgfmt %s -o %s' % (f, out))
-        Logs.info('%s -> %s' % (f, out))
+        bld(rule = 'msgfmt ${SRC} -o ${TGT}', source = bld.path.make_node(po), target = bld.path.get_bld().make_node(mo))
+        bld.install_files(os.path.join('${PREFIX}', 'share', 'locale', lang, 'LC_MESSAGES'), mo)
index 59047c70dd0ca75a88007a520425412f50c4f130..6ddb948515e53c2e8b872bd7c8696093be01c479 100644 (file)
@@ -68,5 +68,7 @@ def build(bld):
     obj.source = sources
     obj.target = 'dvdomatic'
 
+    i18n.po_to_mo(os.path.join('src', 'lib'), 'libdvdomatic', bld)
+
 def pot(bld):
     i18n.pot(os.path.join('src', 'lib'), sources, 'libdvdomatic')
index de130ce17fedbde2d89e02387358e3e284575ac8..64d5efe56e3d8d0c934e5e8a9ef8084c9e2000d3 100644 (file)
@@ -23,9 +23,7 @@ def build(bld):
                 obj.source += ' ../../windows/dvdomatic.rc'
             obj.target = t
 
+        i18n.po_to_mo(os.path.join('src', 'tools'), 'dvdomatic', bld)
+
 def pot(bld):
     i18n.pot(os.path.join('src', 'tools'), 'dvdomatic.cc', 'dvdomatic')
-
-def mo(bld):
-    i18n.po_to_mo(os.path.join('src', 'tools'), 'dvdomatic')
-
index abe39894d4c306be92a4d5e7a52a3946eabeac2f..f7f888acdb541b98e2fcc00de47f97e3a91b0965 100644 (file)
@@ -12,7 +12,3 @@ def pot(bld):
     bld.recurse('lib')
     bld.recurse('wx')
     bld.recurse('tools')
-
-def mo(bld):
-    bld.recurse('wx')
-    bld.recurse('tools')
index a0a4bbe8b27e85f3d9d166143e1bbd26ba1b2641..92ff440cd49be89a50fddb930d2a94beac8589f1 100644 (file)
@@ -38,9 +38,7 @@ def build(bld):
     obj.source = sources
     obj.target = 'dvdomatic-wx'
 
+    i18n.po_to_mo(os.path.join('src', 'wx'), 'libdvdomatic-wx', bld)
+
 def pot(bld):
     i18n.pot(os.path.join('src', 'wx'), sources, 'libdvdomatic-wx')
-
-def mo(bld):
-    i18n.po_to_mo(os.path.join('src', 'wx'), 'libdvdomatic-wx')
-
diff --git a/wscript b/wscript
index 16ef91f3bedcd6b34eae37247e4a26c95e618731..f3df9cfed2e82fafd4dab36d76aa939d719799ef 100644 (file)
--- a/wscript
+++ b/wscript
@@ -23,7 +23,7 @@ def configure(conf):
 
     conf.env.append_value('CXXFLAGS', ['-D__STDC_CONSTANT_MACROS', '-msse', '-mfpmath=sse', '-ffast-math', '-fno-strict-aliasing',
                                        '-Wall', '-Wno-attributes', '-Wextra',
-                                       '-DLOCALE_DIR="%s/share/locale"' % conf.env.prefix])
+                                       '-DLOCALE_DIR="%s/share/locale"' % conf.env['PREFIX']])
 
     if conf.options.target_windows:
         conf.env.append_value('CXXFLAGS', ['-DDVDOMATIC_WINDOWS', '-DWIN32_LEAN_AND_MEAN', '-DBOOST_USE_WINDOWS_H', '-DUNICODE'])
@@ -267,6 +267,3 @@ def post(ctx):
 
 def pot(bld):
     bld.recurse('src')
-
-def mo(bld):
-    bld.recurse('src')