Localization (#1)
authorAdrian Iain Lam <adrianiainlam@gmail.com>
Sat, 17 Sep 2016 18:09:39 +0000 (02:09 +0800)
committerAdrian Iain Lam <adrianiainlam@gmail.com>
Sat, 17 Sep 2016 18:09:39 +0000 (02:09 +0800)
README.md
indicator-keyboard-led.py
locale/default.pot [new file with mode: 0644]
locale/en/LC_MESSAGES/default.mo [new file with mode: 0644]
locale/en/LC_MESSAGES/default.po [new file with mode: 0644]
locale/fr/LC_MESSAGES/default.mo [new file with mode: 0644]
locale/fr/LC_MESSAGES/default.po [new file with mode: 0644]
screenshots/sc7.png [new file with mode: 0644]

index 2d107d8..111d461 100644 (file)
--- 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
 
index 42b4161..86aa543 100755 (executable)
@@ -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 (file)
index 0000000..cbdf24f
--- /dev/null
@@ -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 (file)
index 0000000..1088045
Binary files /dev/null and b/locale/en/LC_MESSAGES/default.mo differ
diff --git a/locale/en/LC_MESSAGES/default.po b/locale/en/LC_MESSAGES/default.po
new file mode 100644 (file)
index 0000000..1370bfd
--- /dev/null
@@ -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 (file)
index 0000000..011f9fc
Binary files /dev/null and b/locale/fr/LC_MESSAGES/default.mo differ
diff --git a/locale/fr/LC_MESSAGES/default.po b/locale/fr/LC_MESSAGES/default.po
new file mode 100644 (file)
index 0000000..e1e6b04
--- /dev/null
@@ -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 "Maj"
+
+# indicator long label
+msgid "Scroll"
+msgstr "Défil"
+
+# indicator short label
+msgid "N"
+msgstr "N"
+
+# indicator short label
+msgid "C"
+msgstr "M"
+
+# indicator short label
+msgid "S"
+msgstr "D"
+
+# menu entry
+msgid "Num Lock"
+msgstr "Verr num"
+
+# menu entry
+msgid "Caps Lock"
+msgstr "Verr Maj"
+
+# menu entry
+msgid "Scroll Lock"
+msgstr "Arrêt défil"
+
+# menu entry
+msgid "Quit"
+msgstr "Quitter"
diff --git a/screenshots/sc7.png b/screenshots/sc7.png
new file mode 100644 (file)
index 0000000..bddc55e
Binary files /dev/null and b/screenshots/sc7.png differ