1
0

download-translation-catalog 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. '''
  4. :codeauthor: Pedro Algarvio (pedro@algarvio.me)
  5. download-translation-catalog
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. Download a translation catalog from Transifex.
  8. '''
  9. # Import python libs
  10. import os
  11. import sys
  12. # Import 3rd-party libs
  13. try:
  14. import txclib.utils
  15. except ImportError:
  16. print(
  17. 'The \'transifex-client\' library needs to be installed. '
  18. 'Please execute one of \'pip install transifex-client\' or '
  19. '\'easy_install transifex-client\''
  20. )
  21. sys.exit(1)
  22. DOC_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
  23. LOCALES_DIR = os.path.join(DOC_DIR, 'locale')
  24. def main():
  25. '''
  26. Run the compile code
  27. '''
  28. os.chdir(DOC_DIR)
  29. tx_root = txclib.utils.find_dot_tx()
  30. if len(sys.argv) < 2:
  31. print('You need to pass a locale to this script. For example: '
  32. 'pt_PT, zh_CN, ru, etc...')
  33. sys.exit(1)
  34. for locale in sys.argv[1:]:
  35. print('Download \'{0}\' translations catalog...'.format(locale))
  36. txclib.utils.exec_command('pull', ['-l', locale], tx_root)
  37. print('Done')
  38. if __name__ == '__main__':
  39. main()