diff --git a/setup/translations.py b/setup/translations.py index 722b1107b3..074fc8dabf 100644 --- a/setup/translations.py +++ b/setup/translations.py @@ -265,10 +265,18 @@ class GetTranslations(Translations): # {{{ description = 'Get updated translations from Transifex' + @property + def is_modified(self): + return bool(subprocess.check_output('git status --porcelain'.split(), cwd=self.TRANSLATIONS)) + def run(self, opts): require_git_master() self.tx('pull -a') - self.check_for_errors() + if self.is_modified: + self.check_for_errors() + self.upload_to_vcs() + else: + print ('No translations were updated') def check_for_errors(self): errors = os.path.join(tempfile.gettempdir(), 'calibre-translation-errors') @@ -310,6 +318,13 @@ class GetTranslations(Translations): # {{{ return True return False + def upload_to_vcs(self): + print ('Uploading updated translations to version control') + cc = partial(subprocess.check_call, cwd=self.TRANSLATIONS) + cc('git add */*.po'.split()) + cc('git commit -am'.split() + ['Updated translations']) + cc('git push'.split()) + # }}} class ISO639(Command): # {{{