[virt-manager PATCH v4 3/9] setup: use msgmerge for updating translations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Switch from intltool to msgmerge to merge the translations to the
catalog, as it is much easier.

Remove the writing of the temporary POTFILES.in, as it is no more needed
now.

Also, since now gettext is used at installation time:
- mention the gettext requirement in INSTALL.md
- add the gettext BuildRequires in the RPM spec file

Signed-off-by: Pino Toscano <ptoscano@xxxxxxxxxx>
---
 INSTALL.md           |  1 +
 setup.py             | 49 +++++---------------------------------------
 virt-manager.spec.in |  1 +
 3 files changed, 7 insertions(+), 44 deletions(-)

diff --git a/INSTALL.md b/INSTALL.md
index 685c400f..7080fce8 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -30,6 +30,7 @@ A detailed dependency list can be found in
 
 Minimum version requirements of major components:
 
+   - gettext
    - python >= 3.4
    - gtk3 >= 3.22
    - libvirt-python >= 0.6.0
diff --git a/setup.py b/setup.py
index 17ea4ef8..25bc5cf3 100755
--- a/setup.py
+++ b/setup.py
@@ -67,28 +67,6 @@ def _generate_meta_potfiles_in():
     return potfiles
 
 
-def _generate_potfiles_in():
-    def find(dirname, ext):
-        ret = []
-        for root, ignore, filenames in os.walk(dirname):
-            for filename in fnmatch.filter(filenames, ext):
-                ret.append(os.path.join(root, filename))
-        ret.sort(key=lambda s: s.lower())
-        return ret
-
-    potfiles = ""
-    potfiles += "\n".join(find("virtManager", "*.py")) + "\n\n"
-    potfiles += "\n".join(find("virtinst", "*.py")) + "\n\n"
-
-    potfiles += _generate_meta_potfiles_in()
-    potfiles += "\n"
-
-    potfiles += "\n".join(["[type: gettext/glade]" + f for
-                          f in find("ui", "*.ui")]) + "\n\n"
-
-    return potfiles
-
-
 class my_build_i18n(distutils.command.build.build):
     """
     Add our desktop files to the list, saves us having to track setup.cfg
@@ -103,30 +81,13 @@ class my_build_i18n(distutils.command.build.build):
         pass
 
     def run(self):
-        potfiles = _generate_potfiles_in()
-        potpath = "po/POTFILES.in"
-
-        try:
-            print("Writing %s" % potpath)
-            open(potpath, "w").write(potfiles)
-            self._run()
-        finally:
-            print("Removing %s" % potpath)
-            os.unlink(potpath)
-
-    def _run(self):
-        # Borrowed from python-distutils-extra
         po_dir = "po"
+        if self.merge_po:
+            pot_file = os.path.join("po", "virt-manager.pot")
+            for po_file in glob.glob("%s/*.po" % po_dir):
+                cmd = ["msgmerge", "--previous", "-o", po_file, po_file, pot_file]
+                self.spawn(cmd)
 
-        # Update po(t) files and print a report
-        # We have to change the working dir to the po dir for intltool
-        cmd = ["intltool-update",
-               (self.merge_po and "-r" or "-p"), "-g", "virt-manager"]
-
-        wd = os.getcwd()
-        os.chdir("po")
-        self.spawn(cmd)
-        os.chdir(wd)
         max_po_mtime = 0
         for po_file in glob.glob("%s/*.po" % po_dir):
             lang = os.path.basename(po_file[:-3])
diff --git a/virt-manager.spec.in b/virt-manager.spec.in
index 1819b9ce..af2591ed 100644
--- a/virt-manager.spec.in
+++ b/virt-manager.spec.in
@@ -49,6 +49,7 @@ Recommends: libvirt-daemon-config-network
 # Optional inspection of guests
 Suggests: python3-libguestfs
 
+BuildRequires: gettext
 BuildRequires: intltool
 BuildRequires: /usr/bin/pod2man
 BuildRequires: python3-devel
-- 
2.26.2




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux