Skip to content

Commit

Permalink
Implement issue #15: Use gettext in order to translate NaturalScrolli…
Browse files Browse the repository at this point in the history
…ng (Use of Launchpad.net)
  • Loading branch information
zedtux committed May 9, 2012
1 parent 2cc20c1 commit bab7296
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 16 deletions.
62 changes: 62 additions & 0 deletions messages.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2012-05-09 21:03+CEST\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"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"


#: naturalscrolling/__init__.py:33
msgid "BrainZ"
msgstr ""

#: naturalscrolling/__init__.py:37
msgid "Show debug messages (-vv debugs naturalscrolling_lib also)"
msgstr ""

#: naturalscrolling/__init__.py:39
msgid "Enable debuging"
msgstr ""

#: naturalscrolling/indicatormenu.py:38
msgid "Start at login"
msgstr ""

#: naturalscrolling/indicatormenu.py:45
msgid "Preferences"
msgstr ""

#: naturalscrolling/indicatormenu.py:50
msgid "About"
msgstr ""

#: naturalscrolling/indicatormenu.py:57
msgid "Quit Natural Scrolling"
msgstr ""

#: naturalscrolling_lib/gconfsettings.py:161
msgid "Can't read the value for type '%s'"
msgstr ""

#: naturalscrolling_lib/gconfsettings.py:175
msgid "Can't write the value '%s' for type '%s'"
msgstr ""

#: naturalscrolling_lib/gconfsettings.py:222
msgid "Warning: The XID of the device with name %s wasn't found"
msgstr ""

#: naturalscrolling_lib/udevobservator.py:56
#: naturalscrolling_lib/udevobservator.py:101
msgid "Warning: The device parent with sys_name %s doesn't have a NAME key."
msgstr ""

8 changes: 6 additions & 2 deletions naturalscrolling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import sys
import optparse
import gettext
gettext.install("naturalscrolling")

from naturalscrolling_lib.naturalscrollingconfig import *
from naturalscrolling.indicator import Indicator
Expand All @@ -28,11 +30,13 @@

def main():
"""Support for command line options"""
print _("BrainZ")

parser = optparse.OptionParser(version="%%prog %s" % appliation_version())
parser.add_option("-v", "--verbose", action="count", dest="verbose",
help="Show debug messages (-vv debugs naturalscrolling_lib also)")
help=_("Show debug messages (-vv debugs naturalscrolling_lib also)"))
parser.add_option("-d", "--debug", action="store_true",
help="Enable debuging")
help=_("Enable debuging"))
(options, args) = parser.parse_args()

if options.debug:
Expand Down
8 changes: 4 additions & 4 deletions naturalscrolling/indicatormenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ def __init__(self):
self.append(self.new_separator())

menu_sub = gtk.Menu()
start_at_login = gtk.CheckMenuItem("Start at login")
start_at_login = gtk.CheckMenuItem(_("Start at login"))
if os.path.isfile(get_auto_start_file_path()):
start_at_login.set_active(True)
start_at_login.connect("activate", self.on_start_at_login_clicked)
menu_sub.append(start_at_login)
start_at_login.show()

preferences = gtk.MenuItem("Preferences")
preferences = gtk.MenuItem(_("Preferences"))
preferences.set_submenu(menu_sub)
self.append(preferences)
preferences.show()

about = gtk.MenuItem("About")
about = gtk.MenuItem(_("About"))
about.connect("activate", self.on_about_clicked)
self.append(about)
about.show()

self.append(self.new_separator())

quit = gtk.MenuItem("Quit Natural Scrolling")
quit = gtk.MenuItem(_("Quit Natural Scrolling"))
quit.connect("activate", self.on_quit_clicked)
self.append(quit)
quit.show()
Expand Down
2 changes: 1 addition & 1 deletion naturalscrolling/xinputwarper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def enable_natural_scrolling(self, devise_xid, enabled):
map = map.replace("5 4", "4 5")
map = map.replace("7 6", "6 7")

os.system("xinput set-button-map \"%s\" %s" %(devise_xid, map))
os.system("xinput set-button-map \"%s\" %s" % (devise_xid, map))

def find_xid_by_name(self, name):
"""
Expand Down
10 changes: 5 additions & 5 deletions naturalscrolling_lib/gconfsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def get_value(self):
elif self.__type == gconf.VALUE_INT:
return self.__gconf.get_int(self.__key)
else:
raise InvalidKeyType("Can't read the value for type '%s'" %
raise InvalidKeyType(_("Can't read the value for type '%s'") %
self.__type)

def set_value(self, value):
Expand All @@ -172,8 +172,8 @@ def set_value(self, value):
elif self.__type == gconf.VALUE_INT:
self.__gconf.set_int(self.__key, value)
else:
raise InvalidKeyType("Can't write the value '%s' for type '%s'" %
(value, self.__type))
raise InvalidKeyType(_("Can't write the value '%s'"
" for type '%s'") % (value, self.__type))

def is_enable(self):
return self.__value == True
Expand Down Expand Up @@ -219,8 +219,8 @@ def initialize(self, devices):
"""
for device in devices:
if not device.keys()[0]:
print ("Warning: The XID of the device with name %s "
"wasn't found" % device.values()[0])
print (_("Warning: The XID of the device with name %s "
"wasn't found") % device.values()[0])
else:
gconf_key = GConfKey(device.keys()[0], gconf.VALUE_BOOL)
gconf_key.find_or_create()
Expand Down
8 changes: 4 additions & 4 deletions naturalscrolling_lib/udevobservator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def gather_devices_names_with_xid(self):
# at the begining and at the end
devices_names.append(device_name)
except KeyError:
print ("Warning: The device parent with sys_name %s "
"doesn't have a NAME key." % device.sys_name)
print (_("Warning: The device parent with sys_name %s"
" doesn't have a NAME key.") % device.sys_name)
except pyudev.DeviceNotFoundAtPathError:
# next() raise this exception when we try to open a removed
# device
Expand Down Expand Up @@ -98,8 +98,8 @@ def on_device_removed(self, observer, device):
xid = XinputWarper().find_xid_by_name(device_name)
GConfSettings().key(xid).remove()
except KeyError:
print ("Warning: The device parent with sys_name %s "
"doesn't have a NAME key." % device.sys_name)
print (_("Warning: The device parent with sys_name %s doesn't"
" have a NAME key.") % device.sys_name)
XinputWarper().reset_cache()

self.__observator(self.gather_devices())

0 comments on commit bab7296

Please sign in to comment.