gajim-plural/scripts/dev/translations.py

78 lines
2.0 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# -*- coding: utf-8 -*-
2005-07-09 02:05:24 +02:00
# Initially written by Nikos Kouremenos
# Dedicated to Yann Le Boulanger
# Usage: './translations.py [help] [stats] [update]'
import os
import sys
stats = False
update = False
2005-08-15 13:41:15 +02:00
check = False
def visit(arg, dirname, names):
if dirname.find('.svn') != -1:
return
if dirname.endswith('LC_MESSAGES'):
if 'gajim.po' in names:
path_to_po = os.path.join(dirname, 'gajim.po')
pos = path_to_po.find('po/') + 3 #3 = len('po/')
2005-09-06 11:49:22 +02:00
endpos = path_to_po.find('/', pos)
name = path_to_po[pos:endpos]
if update: # update an existing po file)
2005-11-09 15:33:51 +01:00
os.system('msgmerge -q -U ../../po/'+name+'/LC_MESSAGES/gajim.po ../../po/gajim.pot')
if stats:
print name, 'has now:'
2005-08-15 13:41:15 +02:00
os.system('msgfmt --statistics ' + path_to_po)
if check:
os.system('msgfmt -c --check-accelerators="_" ' + path_to_po)
2005-09-17 15:56:18 +02:00
else:
print 'PROBLEM: cannot find gajim.po in', dirname
def show_help():
2005-08-15 13:41:15 +02:00
print sys.argv[0], '[help] [stats] [update] [check]'
sys.exit(0)
def update_pot():
# create header for glade strings
2005-11-09 15:33:51 +01:00
os.system('intltool-extract --type=gettext/glade ../../src/gtkgui.glade')
# update the pot
2005-11-09 15:33:51 +01:00
os.system('make -C ../../po/ all gajim.pot')
2005-07-09 02:05:24 +02:00
print 'gajim.pot was updated successfully'
if __name__ == '__main__':
2005-11-09 15:33:51 +01:00
if os.path.basename(os.getcwd()) != 'dev':
2005-11-21 11:33:39 +01:00
print 'run me with cwd: scripts/dev'
sys.exit()
2005-11-09 15:33:51 +01:00
path_to_dir = '../../po'
if len(sys.argv) == 2:
if sys.argv[1].startswith('h'):
show_help()
param = sys.argv[1]
if param == 'stats': # stats only
stats = True
os.path.walk(path_to_dir, visit, None)
2005-08-15 13:41:15 +02:00
elif param == 'update': # update only
update_pot()
update = True
os.path.walk(path_to_dir, visit, None) # update each po & no stats
print 'Done'
2005-08-15 13:41:15 +02:00
elif param == 'check':
check = True
os.path.walk(path_to_dir, visit, None)
2005-08-15 13:41:15 +02:00
elif len(sys.argv) == 1: # update & stats & no check
update_pot()
update = True
stats = True
os.path.walk(path_to_dir, visit, None)
print 'Done'
else:
show_help()