From f462ecb9498e3525c8eea31664c2c03f32219e8d Mon Sep 17 00:00:00 2001 From: Adrian Iain Lam Date: Sun, 18 Sep 2016 02:09:39 +0800 Subject: [PATCH] Localization (#1) --- README.md | 13 ++++++++++- indicator-keyboard-led.py | 24 ++++++++++++--------- locale/default.pot | 45 +++++++++++++++++++++++++++++++++++++++ locale/en/LC_MESSAGES/default.mo | Bin 0 -> 480 bytes locale/en/LC_MESSAGES/default.po | 45 +++++++++++++++++++++++++++++++++++++++ locale/fr/LC_MESSAGES/default.mo | Bin 0 -> 483 bytes locale/fr/LC_MESSAGES/default.po | 45 +++++++++++++++++++++++++++++++++++++++ screenshots/sc7.png | Bin 0 -> 3898 bytes 8 files changed, 161 insertions(+), 11 deletions(-) create mode 100644 locale/default.pot create mode 100644 locale/en/LC_MESSAGES/default.mo create mode 100644 locale/en/LC_MESSAGES/default.po create mode 100644 locale/fr/LC_MESSAGES/default.mo create mode 100644 locale/fr/LC_MESSAGES/default.po create mode 100644 screenshots/sc7.png diff --git a/README.md b/README.md index 2d107d8..111d461 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,17 @@ Hide Scroll lock. `python3 indicator-keyboard-led.py --order NC` 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 @@ -104,7 +109,13 @@ modified. [Original source][origsrc] by dm+ on PCLinuxOS-Forums. [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 diff --git a/indicator-keyboard-led.py b/indicator-keyboard-led.py index 42b4161..86aa543 100755 --- a/indicator-keyboard-led.py +++ b/indicator-keyboard-led.py @@ -37,18 +37,23 @@ gi.require_version('Gtk', '3.0') 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) @@ -56,9 +61,9 @@ class IndicatorKeyboardLED: 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') @@ -67,7 +72,7 @@ class IndicatorKeyboardLED: 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) @@ -107,9 +112,8 @@ if __name__ == '__main__': 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') diff --git a/locale/default.pot b/locale/default.pot new file mode 100644 index 0000000..cbdf24f --- /dev/null +++ b/locale/default.pot @@ -0,0 +1,45 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +# indicator long label +msgid "Num" +msgstr "" + +# indicator long label +msgid "Caps" +msgstr "" + +# indicator long label +msgid "Scroll" +msgstr "" + +# indicator short label +msgid "N" +msgstr "" + +# indicator short label +msgid "C" +msgstr "" + +# indicator short label +msgid "S" +msgstr "" + +# menu entry +msgid "Num Lock" +msgstr "" + +# menu entry +msgid "Caps Lock" +msgstr "" + +# menu entry +msgid "Scroll Lock" +msgstr "" + +# menu entry +msgid "Quit" +msgstr "" diff --git a/locale/en/LC_MESSAGES/default.mo b/locale/en/LC_MESSAGES/default.mo new file mode 100644 index 0000000000000000000000000000000000000000..108804513bb6ab57086b35c5f535c689c03d5e0f GIT binary patch literal 480 zcmbu3KQ9D97{&+Z-)bCjyc~$=&^3WF7qAR+C8*11d4YU_M(JP!S%Yfmev)^gQ zC(6~@npC#dH>1oNuZ)lTca=(|SGRtnDsyeNWpS0eTKS#h{$8B??YZ347s|zLQ`mED OE>oGDX&?RLr+xsH9Z!P* literal 0 HcmV?d00001 diff --git a/locale/en/LC_MESSAGES/default.po b/locale/en/LC_MESSAGES/default.po new file mode 100644 index 0000000..1370bfd --- /dev/null +++ b/locale/en/LC_MESSAGES/default.po @@ -0,0 +1,45 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +# indicator long label +msgid "Num" +msgstr "Num" + +# indicator long label +msgid "Caps" +msgstr "Caps" + +# indicator long label +msgid "Scroll" +msgstr "Scroll" + +# indicator short label +msgid "N" +msgstr "N" + +# indicator short label +msgid "C" +msgstr "C" + +# indicator short label +msgid "S" +msgstr "S" + +# menu entry +msgid "Num Lock" +msgstr "Num Lock" + +# menu entry +msgid "Caps Lock" +msgstr "Caps Lock" + +# menu entry +msgid "Scroll Lock" +msgstr "Scroll Lock" + +# menu entry +msgid "Quit" +msgstr "Quit" diff --git a/locale/fr/LC_MESSAGES/default.mo b/locale/fr/LC_MESSAGES/default.mo new file mode 100644 index 0000000000000000000000000000000000000000..011f9fc730b91b0668ff179043f4ac9976a316a1 GIT binary patch literal 483 zcmYk1&q~8U5XMKX|006biw6&jc<>Un7YQjMl2#B+L0Ua{i|JOQaT7LM&|cvL8?o<;7?bCs}+;Eo$}eSY>+JPYkuG9qTMjEy_xG z6gJ&+sf#32zNl^OI6W2sX>jwOD{?3K=o*Y?%fG zNA^X)k%rI&2#XOEnFb+1b_`^zRH`bqy?V>N{YNF0s>%lQ4fc$a-&fz4SNEQK&hMUk z-nr-A3Ys-@BDCWFHyBBhTNJ{W)VSO}pHEdW0I)10>II`weDw5M@ne7?gfuTv<8qf* zRCn)|+TqD3OhzLCY_r*O^YU-p%t=X3Fc|bd4$)RTIcC z^}(ji9=B5vbdQo@D;_z}OA|&m)6KHNie-x#h5>+z@`}nTD*%d%iAhXK1OP=*maSZa zwU#%ORy+zQ8mIcJMZE#HB#8;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