[Pkg-privacy-commits] [torbrowser-launcher] 07/26: setup: Added compiling of translations from the directory "po"

Ulrike Uhlig u-guest at moszumanska.debian.org
Sat Jan 28 11:59:28 UTC 2017


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to annotated tag v0.2.7
in repository torbrowser-launcher.

commit 3dcb0129d77de16c680b7a510e9c4e2536b6648c
Author: Naru Trey <contact at libnaru.so>
Date:   Sat Dec 3 20:22:35 2016 +0400

    setup: Added compiling of translations from the directory "po"
---
 setup.py | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index d8d8842..faceb62 100644
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 """
 
 from distutils.core import setup
-import os, sys, platform
+import os, sys, platform, subprocess
 SHARE = 'share'
 
 # detect linux distribution
@@ -40,6 +40,25 @@ def file_list(path):
             files.append(path+'/'+filename)
     return files
 
+def create_mo_files():
+    po_dir = 'po/'
+    if not os.path.exists(po_dir):
+        return []
+    domain = 'torbrowser-launcher'
+    mo_files = []
+    po_files = [f
+                for f in next(os.walk(po_dir))[2]
+                if os.path.splitext(f)[1] == '.po']
+    for po_file in po_files:
+        filename, extension = os.path.splitext(po_file)
+        mo_file = domain + '.mo'
+        mo_dir = 'share/locale/' + filename + '/LC_MESSAGES/'
+        subprocess.call('mkdir -p ' + mo_dir, shell=True)
+        msgfmt_cmd = 'msgfmt {} -o {}'.format(po_dir + po_file, mo_dir + mo_file)
+        subprocess.call(msgfmt_cmd, shell=True)
+        mo_files.append(mo_dir + mo_file)
+    return mo_files
+
 with open(os.path.join(SHARE, 'torbrowser-launcher/version')) as buf:
     version = buf.read().strip()
 
@@ -57,6 +76,8 @@ if distro != 'Ubuntu':
             'apparmor/torbrowser.Tor.tor',
             'apparmor/usr.bin.torbrowser-launcher'])]
 
+datafiles += [('/usr/share/locale/', create_mo_files())]
+
 setup(
     name='torbrowser-launcher',
     version=version,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torbrowser-launcher.git



More information about the Pkg-privacy-commits mailing list