Skip to content

Commit

Permalink
Localize the Desktop file
Browse files Browse the repository at this point in the history
  • Loading branch information
cas-- committed Jul 13, 2011
1 parent 1a9be0e commit 81d4b00
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist
*.tar.*
_trial_temp
deluge/i18n/*
*.desktop
21 changes: 21 additions & 0 deletions check_glade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

# Fixes glade files which may have set gtk stock labels set to translatable
for x in `find . -name '*.glade' |grep -v '.git\|build'` ; do \
for y in gtk-add gtk-apply gtk-bold gtk-cancel gtk-cdrom gtk-clear \
gtk-close gtk-color-picker gtk-connect gtk-convert gtk-copy gtk-cut \
gtk-delete gtk-dialog-error gtk-dialog-info gtk-dialog-question \
gtk-dialog-warning gtk-dnd gtk-dnd-multiple gtk-edit gtk-execute gtk-find \
gtk-find-and-replace gtk-floppy gtk-goto-bottom gtk-goto-first \
gtk-goto-last gtk-goto-top gtk-go-back gtk-go-down gtk-go-forward \
gtk-go-up gtk-help gtk-home gtk-index gtk-italic gtk-jump-to \
gtk-justify-center gtk-justify-fill gtk-justify-left gtk-missing-image \
gtk-new gtk-no gtk-ok gtk-open gtk-paste gtk-preferences gtk-print \
gtk-print-preview gtk-properties gtk-quit gtk-redo gtk-refresh \
gtk-remove gtk-revert-to-saved gtk-save gtk-save-as gtk-select-color \
gtk-select-font gtk-sort-descending gtk-spell-check gtk-stop \
gtk-strikethrough gtk-undelete gtk-underline gtk-undo gtk-yes \
gtk-zoom-100 gtk-zoom-fit gtk-zoom-in gtk-zoom-out; do \
sed -i "s/<property\ name\=\"label\"\ translatable\=\"yes\">$y<\/property>/<property\ name\=\"label\"\ translatable\=\"no\">$y<\/property>/g" $x; \
done;\
done
7 changes: 4 additions & 3 deletions create_potfiles_in.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import os
import re

import sys
# Paths to exclude
EXCLUSIONS = [
"deluge/scripts",
Expand All @@ -13,11 +13,12 @@
pattern = "deluge\/plugins\/.*\/build"
compiled = re.compile(pattern)

print "Creating " + POTFILE_IN + " ..."
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") \
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))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[Desktop Entry]
Version=1.0
Name=Deluge
GenericName=BitTorrent Client
X-GNOME-FullName=Deluge BitTorrent Client
Comment=Download and share files over BitTorrent
_Name=Deluge
_GenericName=BitTorrent Client
_X-GNOME-FullName=Deluge BitTorrent Client
_Comment=Download and share files over BitTorrent
TryExec=deluge-gtk
Exec=deluge-gtk %U
Icon=deluge
Expand Down
2 changes: 1 addition & 1 deletion deluge/i18n/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ deluge/core/rpcserver.py
deluge/core/daemon.py
deluge/core/core.py
deluge/core/pluginmanager.py
deluge/data/share/applications/deluge.desktop.in
deluge/ui/ui.py
deluge/ui/common.py
deluge/ui/coreconfig.py
Expand Down Expand Up @@ -155,7 +156,6 @@ deluge/ui/gtkui/glade/connection_manager.glade
deluge/ui/gtkui/glade/preferences_dialog.glade
deluge/ui/gtkui/glade/tray_menu.glade
deluge/ui/gtkui/glade/torrent_menu.glade
deluge/ui/gtkui/glade/remove_torrent_dialog2.glade
deluge/ui/gtkui/glade/edit_trackers.glade
deluge/ui/gtkui/glade/remove_torrent_dialog.glade
deluge/ui/gtkui/glade/move_storage_dialog.glade
Expand Down
51 changes: 25 additions & 26 deletions deluge/i18n/deluge.pot
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# Copyright (C) 2011 Deluge Team
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-07-10 16:58+0100\n"
"Project-Id-Version: Deluge 1.3.2\n"
"Report-Msgid-Bugs-To: http://deluge-torrent.org\n"
"POT-Creation-Date: 2011-07-13 21:23+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -1831,6 +1831,7 @@ msgid "Up:"
msgstr ""

#: deluge/ui/gtkui/systemtray.py:201 deluge/ui/gtkui/systemtray.py:258
#: deluge/data/share/applications/deluge.desktop.in.h:2
msgid "Deluge"
msgstr ""

Expand Down Expand Up @@ -3639,28 +3640,6 @@ msgstr ""
msgid "_Auto Managed"
msgstr ""

#: deluge/ui/gtkui/glade/remove_torrent_dialog2.glade:51
#: deluge/ui/gtkui/glade/remove_torrent_dialog.glade:45
msgid "<big><b>Remove the selected torrent?</b></big>"
msgstr ""

#: deluge/ui/gtkui/glade/remove_torrent_dialog2.glade:66
#: deluge/ui/gtkui/glade/remove_torrent_dialog.glade:57
msgid "If you remove the data, it will be lost permanently."
msgstr ""

#: deluge/ui/gtkui/glade/remove_torrent_dialog2.glade:127
msgid "action"
msgstr ""

#: deluge/ui/gtkui/glade/remove_torrent_dialog2.glade:129
msgid "Remove Files"
msgstr ""

#: deluge/ui/gtkui/glade/remove_torrent_dialog2.glade:198
msgid "Keep Files"
msgstr ""

#: deluge/ui/gtkui/glade/edit_trackers.glade:9
msgid "Edit Trackers"
msgstr ""
Expand Down Expand Up @@ -3689,6 +3668,14 @@ msgstr ""
msgid "Tracker:"
msgstr ""

#: deluge/ui/gtkui/glade/remove_torrent_dialog.glade:45
msgid "<big><b>Remove the selected torrent?</b></big>"
msgstr ""

#: deluge/ui/gtkui/glade/remove_torrent_dialog.glade:57
msgid "If you remove the data, it will be lost permanently."
msgstr ""

#: deluge/ui/gtkui/glade/remove_torrent_dialog.glade:117
msgid "Remove With _Data"
msgstr ""
Expand All @@ -3708,3 +3695,15 @@ msgstr ""
#: deluge/ui/gtkui/glade/move_storage_dialog.glade:78
msgid "Destination:"
msgstr ""

#: deluge/data/share/applications/deluge.desktop.in.h:1
msgid "BitTorrent Client"
msgstr ""

#: deluge/data/share/applications/deluge.desktop.in.h:3
msgid "Deluge BitTorrent Client"
msgstr ""

#: deluge/data/share/applications/deluge.desktop.in.h:4
msgid "Download and share files over BitTorrent"
msgstr ""
44 changes: 25 additions & 19 deletions gettextize.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#!/bin/sh
for x in `find . -name '*.glade' |grep -v '.git\|build'` ; do \
for y in gtk-add gtk-apply gtk-bold gtk-cancel gtk-cdrom gtk-clear \
gtk-close gtk-color-picker gtk-connect gtk-convert gtk-copy gtk-cut \
gtk-delete gtk-dialog-error gtk-dialog-info gtk-dialog-question \
gtk-dialog-warning gtk-dnd gtk-dnd-multiple gtk-edit gtk-execute gtk-find \
gtk-find-and-replace gtk-floppy gtk-goto-bottom gtk-goto-first \
gtk-goto-last gtk-goto-top gtk-go-back gtk-go-down gtk-go-forward \
gtk-go-up gtk-help gtk-home gtk-index gtk-italic gtk-jump-to \
gtk-justify-center gtk-justify-fill gtk-justify-left gtk-missing-image \
gtk-new gtk-no gtk-ok gtk-open gtk-paste gtk-preferences gtk-print \
gtk-print-preview gtk-properties gtk-quit gtk-redo gtk-refresh \
gtk-remove gtk-revert-to-saved gtk-save gtk-save-as gtk-select-color \
gtk-select-font gtk-sort-descending gtk-spell-check gtk-stop \
gtk-strikethrough gtk-undelete gtk-underline gtk-undo gtk-yes \
gtk-zoom-100 gtk-zoom-fit gtk-zoom-in gtk-zoom-out; do \
sed -i "s/<property\ name\=\"label\"\ translatable\=\"yes\">$y<\/property>/<property\ name\=\"label\"\ translatable\=\"no\">$y<\/property>/g" $x; \
done;\
done
xgettext --from-code ISO-8859-1 -f deluge/i18n/POTFILES.in -o deluge/i18n/deluge.pot
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"
26 changes: 22 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,20 @@ def finalize_options(self):

def run(self):
po_dir = os.path.join(os.path.dirname(__file__), 'deluge/i18n/')

# creates the translated desktop file
INTLTOOL_MERGE='intltool-merge'
INTLTOOL_MERGE_OPTS='--utf8 --quiet --desktop-style'
desktop_in='deluge/data/share/applications/deluge.desktop.in'
desktop_data='deluge/data/share/applications/deluge.desktop'
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))

print('Compiling po files from %s...' % po_dir),
for path, names, filenames in os.walk(po_dir):
for f in filenames:
uptoDate = False
if f.endswith('.po'):
lang = f[:len(f) - 3]
src = os.path.join(path, f)
Expand All @@ -264,14 +276,22 @@ def run(self):
if not os.path.exists(dest_path):
os.makedirs(dest_path)
if not os.path.exists(dest):
print('Compiling %s' % src)
sys.stdout.write('%s, ' % lang)
sys.stdout.flush()
msgfmt.make(src, dest)
else:
src_mtime = os.stat(src)[8]
dest_mtime = os.stat(dest)[8]
if src_mtime > dest_mtime:
print('Compiling %s' % src)
sys.stdout.write('%s, ' % lang)
sys.stdout.flush()
msgfmt.make(src, dest)
else:
uptoDate = True

if uptoDate:
sys.stdout.write(' po files already upto date. ')
sys.stdout.write('\b\b \nFinished compiling translation files. \n')

class build_plugins(cmd.Command):
description = "Build plugins into .eggs"
Expand Down Expand Up @@ -507,7 +527,6 @@ def run(self):
libtorrent in it's backend to handle the bittorrent protocol.""",
url = "http://deluge-torrent.org",
license = "GPLv3",

cmdclass = cmdclass,
data_files = _data_files,
ext_package = "deluge",
Expand All @@ -519,7 +538,6 @@ def run(self):
"data/pixmaps/*.gif",
"data/pixmaps/flags/*.png",
"plugins/*.egg",
"i18n/*.pot",
"i18n/*/LC_MESSAGES/*.mo",
"ui/web/gettext.js",
"ui/web/index.html",
Expand Down

0 comments on commit 81d4b00

Please sign in to comment.