Create new generate_pot.py script for translations
* glade3 files require workaround with intltool-extract * webui javascript files are now included * fix multiline string for parse
This commit is contained in:
parent
3959b67cc0
commit
d455d03608
|
@ -6,9 +6,7 @@ docs/source/ export-ignore
|
|||
/tests/ export-ignore
|
||||
deluge/scripts/ export-ignore
|
||||
setup.cfg export-ignore
|
||||
create_potfiles_in.py export-ignore
|
||||
gettextize.sh export-ignore
|
||||
deluge/i18n/deluge.pot export-ignore
|
||||
generate_pot.py export-ignore
|
||||
deluge/ui/web/css/*-debug.css export-ignore
|
||||
deluge/ui/web/js/*-debug.js export-ignore
|
||||
deluge/ui/web/js/deluge-all/ export-ignore
|
||||
|
|
|
@ -8,6 +8,7 @@ dist
|
|||
*.tar.*
|
||||
_trial_temp
|
||||
deluge/i18n/*/
|
||||
deluge.pot
|
||||
*.desktop
|
||||
.build_data*
|
||||
osx/app
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
# Paths to exclude
|
||||
EXCLUSIONS = [
|
||||
"deluge/scripts",
|
||||
"deluge/i18n",
|
||||
]
|
||||
|
||||
POTFILE_IN = "deluge/i18n/POTFILES.in"
|
||||
|
||||
pattern = "deluge\/plugins\/.*\/build"
|
||||
compiled = re.compile(pattern)
|
||||
|
||||
sys.stdout.write("Creating " + POTFILE_IN + " ... ")
|
||||
sys.stdout.flush()
|
||||
to_translate = []
|
||||
for (dirpath, dirnames, filenames) in os.walk("deluge"):
|
||||
for filename in filenames:
|
||||
if os.path.splitext(filename)[1] in (".py", ".glade", ".in") \
|
||||
and dirpath not in EXCLUSIONS \
|
||||
and not compiled.match(dirpath):
|
||||
to_translate.append(os.path.join(dirpath, filename))
|
||||
|
||||
f = open(POTFILE_IN, "wb")
|
||||
for line in to_translate:
|
||||
f.write(line + "\n")
|
||||
|
||||
f.close()
|
||||
|
||||
print "Done"
|
|
@ -1,6 +1,6 @@
|
|||
/*!
|
||||
* Deluge.OptionsManager.js
|
||||
*
|
||||
*
|
||||
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -40,7 +40,7 @@ Ext.namespace('Deluge');
|
|||
* @param {Object} config Configuration options
|
||||
*/
|
||||
Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
|
||||
|
||||
|
||||
constructor: function(config) {
|
||||
config = config || {};
|
||||
this.binds = {};
|
||||
|
@ -82,7 +82,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
|
|||
addOptions: function(options) {
|
||||
this.options = Ext.applyIf(this.options, options);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Binds a form field to the specified option.
|
||||
* @param {String} option
|
||||
|
@ -262,7 +262,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
|
|||
* @private
|
||||
*/
|
||||
onFieldChange: function(field, event) {
|
||||
if (field.field) field = field.field // fix for spinners
|
||||
if (field.field) field = field.field; // fix for spinners
|
||||
this.update(field._doption, field.getValue());
|
||||
},
|
||||
|
||||
|
@ -279,7 +279,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, {
|
|||
// If we don't have a bind there's nothing to do.
|
||||
if (Ext.isEmpty(this.binds[option])) return;
|
||||
Ext.each(this.binds[option], function(bind) {
|
||||
// The field is currently focused so we don't want to
|
||||
// The field is currently focused so we don't want to
|
||||
// change it.
|
||||
if (bind == this.focused) return;
|
||||
// Set the form field to the new value.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*!
|
||||
* Deluge.preferences.OtherPage.js
|
||||
*
|
||||
*
|
||||
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -44,12 +44,12 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
|
|||
}, config);
|
||||
Deluge.preferences.Other.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
|
||||
initComponent: function() {
|
||||
Deluge.preferences.Other.superclass.initComponent.call(this);
|
||||
|
||||
|
||||
var optMan = deluge.preferences.getOptionsManager();
|
||||
|
||||
|
||||
var fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
|
@ -65,7 +65,7 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
|
|||
name: 'new_release_check',
|
||||
boxLabel: _('Be alerted about new releases')
|
||||
}));
|
||||
|
||||
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
|
@ -78,9 +78,9 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
|
|||
xtype: 'panel',
|
||||
border: false,
|
||||
bodyCfg: {
|
||||
html: _('Help us improve Deluge by sending us your '
|
||||
+ 'Python version, PyGTK version, OS and processor '
|
||||
+ 'types. Absolutely no other information is sent.')
|
||||
html: _('Help us improve Deluge by sending us your \
|
||||
Python version, PyGTK version, OS and processor \
|
||||
types. Absolutely no other information is sent.')
|
||||
}
|
||||
});
|
||||
optMan.bind('send_info', fieldset.add({
|
||||
|
@ -90,7 +90,7 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
|
|||
boxLabel: _('Yes, please send anonymous statistics'),
|
||||
name: 'send_info'
|
||||
}));
|
||||
|
||||
|
||||
fieldset = this.add({
|
||||
xtype: 'fieldset',
|
||||
border: false,
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# This script creates the deluge.pot template file for translators
|
||||
#
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from version import get_version
|
||||
from subprocess import call
|
||||
from datetime import datetime
|
||||
|
||||
# Paths to exclude
|
||||
EXCLUSIONS = [
|
||||
"deluge/scripts",
|
||||
"deluge/i18n",
|
||||
"deluge/tests",
|
||||
]
|
||||
webui_js_dir = "deluge/ui/web/js/deluge-all"
|
||||
infiles_list= "infiles.list"
|
||||
pot_filepath = os.path.join("deluge", "i18n", "deluge.pot")
|
||||
|
||||
re_exc_plugin_build = re.compile("deluge\/plugins\/.*\/build")
|
||||
|
||||
xgettext_cmd = [
|
||||
"xgettext",
|
||||
"--from-code=UTF-8",
|
||||
"-kN_:1",
|
||||
"-f%s" % infiles_list,
|
||||
"-o%s" % pot_filepath,
|
||||
"--package-name=%s" % "Deluge",
|
||||
"--copyright-holder=%s" % "Deluge Team",
|
||||
"--package-version=%s" % get_version(prefix='deluge-', suffix='.dev0'),
|
||||
"--msgid-bugs-address=%s" % "http://deluge-torrent.org",
|
||||
]
|
||||
|
||||
to_translate = []
|
||||
for (dirpath, dirnames, filenames) in os.walk("deluge"):
|
||||
for filename in filenames:
|
||||
if dirpath not in EXCLUSIONS and not re_exc_plugin_build.match(dirpath):
|
||||
filepath = os.path.join(dirpath, filename)
|
||||
if os.path.splitext(filepath)[1] in (".py", ".glade"):
|
||||
to_translate.append(filepath)
|
||||
elif filename.endswith(".in"):
|
||||
call(["intltool-extract", "--quiet", "--type=gettext/ini", filepath])
|
||||
to_translate.append(filepath + ".h")
|
||||
elif filename.endswith(".ui"):
|
||||
call(["intltool-extract", "--quiet", "--type=gettext/glade", filepath])
|
||||
to_translate.append(filepath + ".h")
|
||||
|
||||
with open(infiles_list, "wb") as f:
|
||||
for line in to_translate:
|
||||
f.write(line + "\n")
|
||||
|
||||
# Create pot file from file list
|
||||
call(xgettext_cmd)
|
||||
|
||||
# find javascript files
|
||||
js_to_translate=[]
|
||||
for (dirpath, dirnames, filenames) in os.walk(webui_js_dir):
|
||||
for filename in filenames:
|
||||
if os.path.splitext(filename)[1] == ".js":
|
||||
js_to_translate.append(os.path.join(dirpath, filename))
|
||||
|
||||
with open(infiles_list, "wb") as f:
|
||||
for line in js_to_translate:
|
||||
f.write(line + "\n")
|
||||
|
||||
# Force xgettext language to parse javascript and update pot file
|
||||
output = call(xgettext_cmd + ["--language=Python", "-j"])
|
||||
print "====== Javascript 'unterminated string' warnings can be ignored ======"
|
||||
|
||||
# Replace YEAR and PACKAGE in the copyright message
|
||||
with open(pot_filepath, "r") as f:
|
||||
lines = f.readlines()
|
||||
with open(pot_filepath, "w") as f:
|
||||
for line in lines:
|
||||
if "YEAR" in line:
|
||||
line = line.replace("YEAR", str(datetime.now().year))
|
||||
elif "PACKAGE" in line:
|
||||
line = line.replace("PACKAGE", "Deluge")
|
||||
f.write(line)
|
||||
|
||||
# Clean up temp files
|
||||
os.remove(infiles_list)
|
||||
for filepath in to_translate:
|
||||
if filepath.endswith(".h"):
|
||||
os.remove(filepath)
|
||||
|
||||
print "Created %s" % pot_filepath
|
|
@ -1,26 +0,0 @@
|
|||
#!/bin/sh
|
||||
PACKAGE="Deluge"
|
||||
PKG_VERSION=`grep "version\ =\ \"" setup.py | cut -d '"' -f2`
|
||||
PO_DIR="deluge/i18n"
|
||||
POTFILES_IN="infiles.list"
|
||||
POT_FILE=deluge.pot
|
||||
|
||||
cp $PO_DIR/POTFILES.in $POTFILES_IN
|
||||
DESKTOP_FILE=`grep ".*desktop.in$" $POTFILES_IN`
|
||||
|
||||
if [ $DESKTOP_FILE ]; then
|
||||
sed -i "\:$DESKTOP_FILE:d" $POTFILES_IN
|
||||
intltool-extract --quiet --type=gettext/ini $DESKTOP_FILE
|
||||
echo "$DESKTOP_FILE.h" >> $POTFILES_IN
|
||||
fi
|
||||
|
||||
xgettext --from-code=UTF-8 -kN_:1 -f $POTFILES_IN -o $PO_DIR/$POT_FILE --package-name=$PACKAGE \
|
||||
--copyright-holder='Deluge Team' --package-version=$PKG_VERSION \
|
||||
--msgid-bugs-address=http://deluge-torrent.org
|
||||
|
||||
# sub the YEAR in the copyright message
|
||||
sed -i -e '2s/YEAR/'`date +%Y`'/' "$PO_DIR/$POT_FILE"
|
||||
|
||||
rm -f $POTFILES_IN
|
||||
rm -f "$DESKTOP_FILE.h"
|
||||
echo "Created $PO_DIR/$POT_FILE"
|
Loading…
Reference in New Issue