From 1c6ddefbf9b2efa6c4ff461bb4c587f151889e32 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 26 Nov 2014 12:54:17 +0530 Subject: [PATCH] Make user manual translations stats available to calibre --- .gitignore | 1 + setup/resources.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 72a7f60a4d..c655820ef9 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ resources/builtin_recipes.xml resources/builtin_recipes.zip resources/template-functions.json resources/editor-functions.json +resources/user-manual-translation-stats.json icons/icns/*.iconset setup/installer/windows/calibre/build.log tags diff --git a/setup/resources.py b/setup/resources.py index 2704351d88..38654ed79d 100644 --- a/setup/resources.py +++ b/setup/resources.py @@ -328,6 +328,12 @@ class Resources(Command): # {{{ src = '\n'.join(imports) + '\n\n' + src function_dict[func.name] = src json.dump(function_dict, open(dest, 'wb'), indent=4) + self.info('\tCreating user-manual-translation-stats.json') + d = {} + for lc, stats in json.load(open(self.j(self.d(self.SRC), 'manual', 'locale', 'completed.json'))).iteritems(): + total = sum(stats.itervalues()) + d[lc] = stats['translated'] / float(total) + json.dump(d, open(self.j(self.RESOURCES, 'user-manual-translation-stats.json'), 'wb'), indent=4) def clean(self): for x in ('scripts', 'ebook-convert-complete'): @@ -338,7 +344,7 @@ class Resources(Command): # {{{ kakasi.clean() coffee.clean() for x in ('builtin_recipes.xml', 'builtin_recipes.zip', - 'template-functions.json'): + 'template-functions.json', 'user-manual-translation-stats.json'): x = self.j(self.RESOURCES, x) if os.path.exists(x): os.remove(x)