Show Caps lock only, short appearance.
`python3 indicator-keyboard-led.py --short --order C`
+![indicator default, French locale][sc7]
+Default appearance in a French locale.
+`LANGUAGE=fr_FR python3 indicator-keyboard-led.py`
+
[sc1]: screenshots/sc1.png
[sc2]: screenshots/sc2.png
[sc3]: screenshots/sc3.png
[sc4]: screenshots/sc4.png
[sc5]: screenshots/sc5.png
[sc6]: screenshots/sc6.png
+[sc7]: screenshots/sc7.png
## Known bugs
[origsrc]: http://www.pclinuxos.com/forum/index.php/topic,125690.msg1052201.html?PHPSESSID=2qsv83lve6dgd0ivq14bfcjc30#msg1052201
[quotesrc]: http://askubuntu.com/a/597757/274080
-
+
+## Localization
+
+As motivated by Issue #1, this script has been localized to French (with
+the assistance of Wikipedia and Google Translate). Corrections to the
+translation, as well as translations to other languages, are welcome.
+Feel free to create a pull request or open an issue.
## License
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gdk, Gtk, AppIndicator3
+SCRIPT_DIR = path.dirname(path.realpath(__file__))
+import gettext
+t = gettext.translation('default', path.join(SCRIPT_DIR, 'locale'))
+_ = t.gettext
+
class IndicatorKeyboardLED:
- locks = { 'N': 'Num', 'C': 'Caps', 'S': 'Scroll' }
+ locks = { 'N': _('Num'), 'C': _('Caps'), 'S': _('Scroll') }
def __init__(self, short=False, order='NCS'):
self.indicator = AppIndicator3.Indicator.new(
'indicator-keyboard-led',
- path.join(path.dirname(path.realpath(__file__)), 'icon.svg'),
+ path.join(SCRIPT_DIR, 'icon.svg'),
AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
if short:
- self.locks = { 'N': 'N', 'C': 'C', 'S': 'S' }
+ self.locks = { 'N': _('N'), 'C': _('C'), 'S': _('S') }
keymap = Gdk.Keymap.get_default()
keymap.connect('state-changed', self.update_indicator, order)
menu = Gtk.Menu()
items = {
- 'N': Gtk.MenuItem.new_with_label('Num Lock'),
- 'C': Gtk.MenuItem.new_with_label('Caps Lock'),
- 'S': Gtk.MenuItem.new_with_label('Scroll Lock')
+ 'N': Gtk.MenuItem.new_with_label(_('Num Lock')),
+ 'C': Gtk.MenuItem.new_with_label(_('Caps Lock')),
+ 'S': Gtk.MenuItem.new_with_label(_('Scroll Lock'))
}
items['N'].connect('activate', self.send_keypress, 'Num_Lock')
items['C'].connect('activate', self.send_keypress, 'Caps_Lock')
for i in order:
menu.append(items[i])
- quit_item = Gtk.MenuItem.new_with_label('Quit')
+ quit_item = Gtk.MenuItem.new_with_label(_('Quit'))
menu.append(Gtk.SeparatorMenuItem())
menu.append(quit_item)
quit_item.connect('activate', Gtk.main_quit)
parser = argparse.ArgumentParser(
description='indicator-keyboard-led - simulate keyboard lock keys LED',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
- parser.add_argument('-s', '--short', action='store_true',
- help='use short label, i.e. ⚫N ⚫C ⚫S instead of ⚫Num ⚫Caps ⚫Scroll',
- required=False)
+ parser.add_argument('-s', '--short', required=False, action='store_true',
+ help='use short label, i.e. ⚫N ⚫C ⚫S instead of ⚫Num ⚫Caps ⚫Scroll')
parser.add_argument('-o', '--order', required=False, default='NCS',
help='specify the order of the locks displayed, e.g. CSN for '
'⚫Caps ⚫Scroll ⚫Num, or NC for ⚫Num ⚫Caps without Scroll lock')