[UI] Refactor appdata.xml code and markup translatable text
This commit is contained in:
parent
3529036f55
commit
4df88c0df3
|
@ -12,6 +12,7 @@ _trial_temp
|
|||
deluge/i18n/*/
|
||||
deluge.pot
|
||||
*.desktop
|
||||
*.appdata.xml
|
||||
.build_data*
|
||||
osx/app
|
||||
RELEASE-VERSION
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>GPL-2.0+</project_license>
|
||||
<translation type="gettext">deluge</translation>
|
||||
<name>Deluge BitTorrent Client</name>
|
||||
<developer_name>Deluge Team</developer_name>
|
||||
<summary>Deluge is a lightweight, Free Software, cross-platform BitTorrent client.</summary>
|
||||
<_name>Deluge BitTorrent Client</_name>
|
||||
<_developer_name>Deluge Team</_developer_name>
|
||||
<_summary>Deluge is a lightweight, Free Software, cross-platform BitTorrent client.</_summary>
|
||||
<url type="homepage">http://www.deluge-torrent.org/</url>
|
||||
<url type="bugtracker">http://dev.deluge-torrent.org</url>
|
||||
<description>
|
||||
|
|
|
@ -80,11 +80,11 @@ def create_gettext_js(js_dir):
|
|||
locations.append((os.path.basename(filename), lineno + 1))
|
||||
strings[string] = locations
|
||||
|
||||
gettext_tpl = '''GetText={maps:{},\
|
||||
add:function(string,translation) {this.maps[string]=translation},\
|
||||
get:function(string) {if (this.maps[string]) {string=this.maps[string]} return string}}
|
||||
function _(string) {return GetText.get(string)}
|
||||
'''
|
||||
gettext_tpl = (
|
||||
'GetText={maps:{},'
|
||||
'add:function(string,translation){this.maps[string]=translation},'
|
||||
'get:function(string){if (this.maps[string]){string=this.maps[string]} return string}};'
|
||||
'function _(string){return GetText.get(string)}')
|
||||
|
||||
gettext_file = os.path.join(os.path.dirname(js_dir), 'gettext.js')
|
||||
with open(gettext_file, 'w') as fp:
|
||||
|
|
|
@ -53,12 +53,18 @@ for (dirpath, dirnames, filenames) in os.walk('deluge'):
|
|||
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')
|
||||
else:
|
||||
if filename.endswith('.xml.in'):
|
||||
gtxt_type = 'gettext/xml'
|
||||
elif filename.endswith('.in'):
|
||||
gtxt_type = 'gettext/ini'
|
||||
elif filename.endswith('.ui'):
|
||||
gtxt_type = 'gettext/glade'
|
||||
else:
|
||||
continue
|
||||
call(['intltool-extract', '--quiet', '--type=%s' % gtxt_type, filepath])
|
||||
filepath += '.h'
|
||||
to_translate.append(filepath)
|
||||
|
||||
with open(INFILES_LIST, 'w') as f:
|
||||
for line in to_translate:
|
||||
|
|
33
setup.py
33
setup.py
|
@ -182,20 +182,19 @@ class BuildTranslations(cmd.Command):
|
|||
basedir = os.path.join(self.build_lib, 'deluge', 'i18n')
|
||||
|
||||
if not windows_check():
|
||||
# creates the translated desktop file
|
||||
intltool_merge = 'intltool-merge'
|
||||
intltool_merge_opts = '--utf8 --quiet --desktop-style'
|
||||
desktop_in = 'deluge/ui/data/share/applications/deluge.desktop.in'
|
||||
print('Creating desktop file: %s' % desktop_data)
|
||||
os.system('C_ALL=C ' + '%s ' * 5 % (intltool_merge, intltool_merge_opts,
|
||||
po_dir, desktop_in, desktop_data))
|
||||
intltool_merge_opts = '--utf8 --quiet'
|
||||
for data_file in (desktop_data, appdata_data):
|
||||
# creates the translated file from .in file.
|
||||
in_file = data_file + '.in'
|
||||
if 'xml' in data_file:
|
||||
intltool_merge_opts += ' --xml-style'
|
||||
elif 'desktop' in data_file:
|
||||
intltool_merge_opts += ' --desktop-style'
|
||||
|
||||
# creates the translated appdata.xml file
|
||||
intltool_merge_opts = '--utf8 --quiet --xml-style'
|
||||
appdata_in = 'deluge/ui/data/share/appdata/deluge.appdata.xml.in'
|
||||
print('Creating appdata.xml file: %s' % appdata_data)
|
||||
os.system('C_ALL=C ' + '%s ' * 5 % (intltool_merge, intltool_merge_opts,
|
||||
po_dir, appdata_in, appdata_data))
|
||||
print('Creating file: %s' % data_file)
|
||||
os.system('C_ALL=C ' + '%s ' * 5 % (
|
||||
intltool_merge, intltool_merge_opts, po_dir, in_file, data_file))
|
||||
|
||||
print('Compiling po files from %s...' % po_dir)
|
||||
for path, names, filenames in os.walk(po_dir):
|
||||
|
@ -239,12 +238,10 @@ class CleanTranslations(cmd.Command):
|
|||
self.set_undefined_options('clean', ('all', 'all'))
|
||||
|
||||
def run(self):
|
||||
if os.path.isfile(desktop_data):
|
||||
print('Deleting %s' % desktop_data)
|
||||
os.remove(desktop_data)
|
||||
if os.path.isfile(appdata_data):
|
||||
print('Deleting %s' % appdata_data)
|
||||
os.remove(appdata_data)
|
||||
for path in (desktop_data, appdata_data):
|
||||
if os.path.isfile(path):
|
||||
print('Deleting %s' % path)
|
||||
os.remove(path)
|
||||
|
||||
|
||||
class BuildPlugins(cmd.Command):
|
||||
|
|
Loading…
Reference in New Issue