[gtk-mac-bundler] Move translation copy to Translation::copy_target().
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-mac-bundler] Move translation copy to Translation::copy_target().
- Date: Sun, 8 Jan 2017 02:07:57 +0000 (UTC)
commit 19110c086763ed6632d2dbdb2e6ecd729cd37b6f
Author: John Ralls <jralls ceridwen us>
Date: Sat Dec 31 12:48:47 2016 -0800
Move translation copy to Translation::copy_target().
bundler/bundler.py | 28 ++--------------------------
bundler/project.py | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/bundler/bundler.py b/bundler/bundler.py
index b8edaab..c27d2c0 100644
--- a/bundler/bundler.py
+++ b/bundler/bundler.py
@@ -435,32 +435,8 @@ class Bundler:
theme.copy_icons(self.project, used_icons)
def copy_translations(self):
- translations = self.project.get_translations()
- prefix = self.project.get_prefix()
-
-
- def name_filter(filename):
- path, fname = os.path.split(filename)
- name, ext = os.path.splitext(fname)
- if name != program.name:
- return False
- elif ext not in (".mo", ".po"):
- return False
- else:
- return True
-
- for program in translations:
- if program.name == "" or program.name == None:
- raise "No program name to tranlate!"
-
- source = self.project.evaluate_path(program.source)
- if source == None:
- raise "Failed to parse translation source!"
- for root, trees, files in os.walk(source):
- for file in filter(name_filter, files):
- path = os.path.join(root, file)
- Path("${prefix}" + path[len(prefix):], program.dest).copy_target(self.project)
-
+ for translation in self.project.get_translations():
+ translation.copy_target(self.project)
def install_gir(self):
gir_files = self.project.get_gir()
diff --git a/bundler/project.py b/bundler/project.py
index 61bf6d6..d0bfd30 100644
--- a/bundler/project.py
+++ b/bundler/project.py
@@ -260,6 +260,26 @@ class Translation(Path):
super(Translation, self).__init__(sourcepath, destpath, recurse)
self.name = name
+ def copy_target(self, project):
+ if not self.name:
+ raise "No program name to tranlate!"
+
+ def name_filter(filename):
+ name, ext = os.path.splitext(os.path.split(filename)[1])
+ if name != self.name or ext not in (".mo", ".po"):
+ return False
+ return True
+
+ source = project.evaluate_path(self.source)
+ if source == None:
+ raise "Failed to parse %s translation source!" % self.name
+ prefix = project.get_prefix()
+ for root, trees, files in os.walk(source):
+ for file in filter(name_filter, files):
+ path = os.path.join(root, file)
+ Path("${prefix}" + path[len(prefix):], self.dest).copy_target(project)
+
+
class GirFile(Path):
def __init__(self, sourcepath, destpath, recurse):
super(GirFile, self).__init__(sourcepath, destpath, recurse)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]