Advertisement
Guest User

Fetch and compile zh_CN po files of Etoys

a guest
Mar 12th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. #!/usr/bin/env python2
  2.  
  3. import os.path
  4. import subprocess
  5.  
  6.  
  7. PO_DIR = "po-files"
  8.  
  9. def checkout():
  10.     subprocess.call([ "svn",
  11.                       "checkout",
  12.                       "http://etoys.squeak.org/svn/trunk/po/zh_CN/",
  13.                       PO_DIR ])
  14.    
  15. def update():
  16.     subprocess.call([ "svn", "update", PO_DIR ])
  17.  
  18.    
  19. def compile_po():
  20.     for fname in os.listdir(PO_DIR):
  21.         if not fname.endswith(".po"):
  22.             continue
  23.    
  24.         po = os.path.join(PO_DIR, fname)
  25.         mo = fname.replace(".po", ".mo")
  26.         subprocess.call([ "msgfmt", "-o", mo, po ])
  27.  
  28.    
  29. if __name__ == '__main__':
  30.     if os.path.exists(PO_DIR):
  31.         update()
  32.     else:
  33.         checkout()
  34.  
  35.     compile_po()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement