2005-06-02 12:47:44 +02:00
|
|
|
#!/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]'
|
2005-06-02 12:47:44 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
stats = False
|
|
|
|
update = False
|
2005-08-15 13:41:15 +02:00
|
|
|
check = False
|
2006-05-10 21:20:16 +02:00
|
|
|
path_to_dir = '../../po'
|
2005-06-02 12:47:44 +02:00
|
|
|
|
2006-05-10 21:20:16 +02:00
|
|
|
def visit(files):
|
|
|
|
for file in files:
|
|
|
|
if file.endswith('.po'):
|
|
|
|
path_to_po = os.path.join(path_to_dir, file)
|
2005-08-03 01:42:37 +02:00
|
|
|
if update: # update an existing po file)
|
2006-05-10 21:20:16 +02:00
|
|
|
os.system('msgmerge -q -U %s %s' % (path_to_po, os.path.join(path_to_dir, 'gajim.pot')))
|
2005-06-02 12:47:44 +02:00
|
|
|
if stats:
|
2006-05-10 21:20:16 +02:00
|
|
|
print file[:-3], 'has now:'
|
2005-08-15 13:41:15 +02:00
|
|
|
os.system('msgfmt --statistics ' + path_to_po)
|
|
|
|
if check:
|
2006-01-11 02:46:45 +01:00
|
|
|
os.system('msgfmt -c ' + path_to_po)
|
2005-06-02 12:47:44 +02:00
|
|
|
|
|
|
|
def show_help():
|
2005-08-15 13:41:15 +02:00
|
|
|
print sys.argv[0], '[help] [stats] [update] [check]'
|
2005-06-02 12:47:44 +02:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
def update_pot():
|
2005-08-03 01:42:37 +02:00
|
|
|
# create header for glade strings
|
2006-05-02 17:53:25 +02:00
|
|
|
os.system("""
|
|
|
|
for i in `ls ../../data/glade/*.glade`;do
|
|
|
|
intltool-extract --type=gettext/glade $i
|
|
|
|
done
|
|
|
|
""")
|
2005-08-03 01:42:37 +02:00
|
|
|
# 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'
|
2005-06-02 12:47:44 +02:00
|
|
|
|
|
|
|
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'
|
2005-06-02 12:47:44 +02:00
|
|
|
sys.exit()
|
|
|
|
|
2005-11-09 15:33:51 +01:00
|
|
|
path_to_dir = '../../po'
|
2005-06-02 12:47:44 +02:00
|
|
|
|
2006-05-10 21:20:16 +02:00
|
|
|
files = os.listdir(path_to_dir)
|
2005-06-02 12:47:44 +02:00
|
|
|
if len(sys.argv) == 2:
|
|
|
|
if sys.argv[1].startswith('h'):
|
|
|
|
show_help()
|
|
|
|
|
|
|
|
param = sys.argv[1]
|
|
|
|
if param == 'stats': # stats only
|
|
|
|
stats = True
|
2006-05-10 21:20:16 +02:00
|
|
|
visit(files)
|
2005-08-15 13:41:15 +02:00
|
|
|
elif param == 'update': # update only
|
2005-06-02 12:47:44 +02:00
|
|
|
update_pot()
|
|
|
|
update = True
|
2006-05-10 21:20:16 +02:00
|
|
|
visit(files)
|
2005-06-02 12:47:44 +02:00
|
|
|
print 'Done'
|
2005-08-15 13:41:15 +02:00
|
|
|
elif param == 'check':
|
|
|
|
check = True
|
2006-05-10 21:20:16 +02:00
|
|
|
visit(files)
|
2005-06-02 12:47:44 +02:00
|
|
|
|
2005-08-15 13:41:15 +02:00
|
|
|
elif len(sys.argv) == 1: # update & stats & no check
|
2005-06-02 12:47:44 +02:00
|
|
|
update_pot()
|
|
|
|
update = True
|
|
|
|
stats = True
|
2006-05-10 21:20:16 +02:00
|
|
|
visit(files)
|
2005-06-02 12:47:44 +02:00
|
|
|
print 'Done'
|
|
|
|
|
|
|
|
else:
|
|
|
|
show_help()
|
|
|
|
|