From 3ee59edda82d5055e41f4f11846c86c301106d8a Mon Sep 17 00:00:00 2001 From: Antoine Choppin Date: Sun, 17 Jul 2016 20:37:41 +0900 Subject: [PATCH 1/3] i18n hooks and initial Japanese translation --- .gitignore | 3 + TRANSLATION.md | 58 ++++++++++++ bin/kano-feedback | 7 ++ debian/control | 4 +- debian/rules | 1 + kano_feedback/DataSender.py | 14 +-- kano_feedback/FeedbackWindow.py | 30 +++---- kano_feedback/MainWindow.py | 32 +++---- kano_feedback/WidgetWindow.py | 6 +- lxpanel-plugin/kano_feedback.c | 15 +++- po/Makefile | 38 ++++++++ po/POTFILES | 1 + po/PYPOTFILES | 6 ++ po/ja.po | 150 ++++++++++++++++++++++++++++++++ 14 files changed, 319 insertions(+), 46 deletions(-) create mode 100644 TRANSLATION.md create mode 100644 po/Makefile create mode 100644 po/POTFILES create mode 100644 po/PYPOTFILES create mode 100644 po/ja.po diff --git a/.gitignore b/.gitignore index 0d20b64..d4d126c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ *.pyc +*.mo +*~ +po/messages.pot diff --git a/TRANSLATION.md b/TRANSLATION.md new file mode 100644 index 0000000..88efcd4 --- /dev/null +++ b/TRANSLATION.md @@ -0,0 +1,58 @@ +# Translation + +Translation files are found in the `po/` directory. + +## i18n not released yet + +Kano OS is not fully i18n-aware and locales are not installed for end users, yet. You can translate this application, but as of now, users will still see the default English message strings. + +## How to add a new translation + +In this example, we're going to add a French translation: + + # install your target locale `fr_FR.utf8` with: + sudo dpkg-reconfigure locales + + cd po/ + # create messages.pot + make messages + + # create fr.po from messages.pot: + msginit -l fr_FR.utf8 + + # now use your favourite editor to translate fr.po + + # build locale files: + make + + cd .. + +## How to make sure your code is i18n-aware + +Add the gettext `_()` macro to all the user-visible message strings in your Python. List the Python source files that contain message strings in `PYPOTFILES`. + +If you added new message strings or made changes to existing ones, do `make messages` to keep the template file up-to-date. + +After that, merge the existing translations with `make update` and ask your translators to update their translations. + +## gettext explained (in 20 seconds) + +* User-visible strings in the source are marked with a macro of your choice. Usually, it's `_()`. +* `xgettext` extracts these message strings from your sources and puts them into a template file. +* This template file, usually named `messages.pot`, contains all user-visible strings of the project, but no translations. +* Translators use `msginit` to copy the template file into a new *portable object* file for their language (explained above). +* The translations are put into `.po`. It's a plain-text file format, you can use any text editor. +* More convenient, specialized `.po`-editors and web-based tools such as Pootle exist, as well. +* If your template file changes, use `msgmerge` to merge your existing translations with the new template, then re-translate the updated messages. Beware of `msgmerge`'s "fuzzy" matches. +* `msgfmt` converts a `.po` file into a binary *message object* file. +* You don't link these `.mo` files with your application binary. +* The `.mo` files are bundled alongside with your software as part of the distribution package. +* During installation, the `.mo` files are copied into the system's locale directory, usually `/usr/share/locale`. +* On startup, your application will look for the message object file that it needs for the current system locale. +* The locale even allows you to provide region-specific translations, e.g. "colour" for en_UK vs "color" for en_US. +* At runtime, all user-visible strings are being replaced with the translations. +* If no message object was found for the system locale, the original strings will be shown. + +## To-Do + +Pootle or Transifex integration. diff --git a/bin/kano-feedback b/bin/kano-feedback index b0a6d85..b3c6d5c 100755 --- a/bin/kano-feedback +++ b/bin/kano-feedback @@ -16,6 +16,13 @@ if __name__ == '__main__' and __package__ is None: dir_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) if dir_path != '/usr': sys.path.insert(0, dir_path) + locale_path = os.path.join(dir_path, 'locale') + else: + locale_path = None + +import kano_i18n.init +kano_i18n.init.install('kano-toolset', locale_path) + from kano_feedback.FeedbackWindow import FeedbackWindow diff --git a/debian/control b/debian/control index 123caac..dcf3eef 100644 --- a/debian/control +++ b/debian/control @@ -4,12 +4,12 @@ Section: misc Priority: optional Standards-Version: 3.9.4 Build-Depends: debhelper (>= 9), build-essential, pkg-config, libgtk2.0-dev, - lxpanel, libfm-dev, libkdesk-dev + lxpanel, libfm-dev, libkdesk-dev, gettext Package: kano-feedback Architecture: any Depends: ${misc:Depends}, curl, kano-toolset (>= 2.4.0-1), kano-profile, kano-video, kano-video-files (>=1.1-2), feh, libkdesk-dev, lsof, - kano-content + kano-content, kano-i18n Description: A tool for feedback gathering A tool to allow Kanux users to provide feedback diff --git a/debian/rules b/debian/rules index 4f9e2b9..48050d9 100755 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,7 @@ #!/usr/bin/make -f %: + cd po && make dh $@ override_dh_auto_build: diff --git a/kano_feedback/DataSender.py b/kano_feedback/DataSender.py index a613aea..70be17c 100644 --- a/kano_feedback/DataSender.py +++ b/kano_feedback/DataSender.py @@ -445,8 +445,8 @@ def send_question_response(question_id, answer, interactive=True): endpoint. ''' - ok_msg_title = 'Thank you' - ok_msg_body = 'We will use your feedback to improve your experience' + ok_msg_title = _('Thank you') + ok_msg_body = _('We will use your feedback to improve your experience') if interactive and not try_connect() or not try_login(): # The answer will be saved as offline, act as if it was sent correctly @@ -481,16 +481,16 @@ def send_question_response(question_id, answer, interactive=True): return False retry = KanoDialog( - title_text='Unable to send', - description_text=('Error while sending your feedback. ' \ - 'Do you want to retry?'), + title_text=_('Unable to send'), + description_text=(_('Error while sending your feedback. ' \ + 'Do you want to retry?')), button_dict={ - 'Close feedback'.upper(): + _('Close feedback').upper(): { 'return_value': False, 'color': 'red' }, - 'Retry'.upper(): + _('Retry').upper(): { 'return_value': True, 'color': 'green' diff --git a/kano_feedback/FeedbackWindow.py b/kano_feedback/FeedbackWindow.py index 7ef7506..2559066 100644 --- a/kano_feedback/FeedbackWindow.py +++ b/kano_feedback/FeedbackWindow.py @@ -22,7 +22,7 @@ def __init__(self, bug_report=False): ''' Initialises the window, creating a report or contact window ''' - MainWindow.__init__(self, subject='Kano Desktop Feedback Widget') + MainWindow.__init__(self, subject=_('Kano Desktop Feedback Widget')) self.bug_report = bug_report if self.bug_report: self.report_window() @@ -38,7 +38,7 @@ def contact_window(self): delete_tmp_dir() create_tmp_dir() - ApplicationWindow.__init__(self, 'Contact Us', self.WIDTH, 0.35) + ApplicationWindow.__init__(self, _('Contact Us'), self.WIDTH, 0.35) screen = Gdk.Screen.get_default() specific_provider = Gtk.CssProvider() @@ -54,7 +54,7 @@ def contact_window(self): self._grid = Gtk.Grid() # Create top bar - self._top_bar = TopBar(title="Contact Us", window_width=self.WIDTH, + self._top_bar = TopBar(title=_("Contact Us"), window_width=self.WIDTH, has_buttons=False) self._top_bar.set_close_callback(Gtk.main_quit) self.set_decorated(True) @@ -67,7 +67,7 @@ def contact_window(self): self._text.set_size_request(self.WIDTH, -1) self._textbuffer = self._text.get_buffer() - self._textbuffer.set_text("Type your feedback here!") + self._textbuffer.set_text(_("Type your feedback here!")) self._clear_buffer_handler_id = self._textbuffer.connect("insert-text", self.clear_buffer) @@ -121,7 +121,7 @@ def report_window(self): Report window Contains 2 text views and Take Screenshot, Add Image and Send buttons ''' - ApplicationWindow.__init__(self, 'Report a Problem', self.WIDTH, 0.35) + ApplicationWindow.__init__(self, _('Report a Problem'), self.WIDTH, 0.35) screen = Gdk.Screen.get_default() specific_provider = Gtk.CssProvider() @@ -134,14 +134,14 @@ def report_window(self): self._grid = Gtk.Grid() # Create top bar - self._top_bar = TopBar(title="Report a Problem", + self._top_bar = TopBar(title=_("Report a Problem"), window_width=self.WIDTH, has_buttons=False) self._top_bar.set_close_callback(Gtk.main_quit) self.set_decorated(True) self.set_titlebar(self._top_bar) self.entry = Gtk.Entry() - self.entry.props.placeholder_text = "Add subject (optional)" + self.entry.props.placeholder_text = _("Add subject (optional)") self.entry.set_margin_left(20) self.entry.set_margin_right(20) self.entry.set_margin_top(20) @@ -155,7 +155,7 @@ def report_window(self): self._text.set_size_request(self.WIDTH, -1) self._textbuffer = self._text.get_buffer() - self._textbuffer.set_text("Type your problem here!") + self._textbuffer.set_text(_("Type your problem here!")) self._clear_buffer_handler_id = self._textbuffer.connect("insert-text", self.clear_buffer) @@ -182,18 +182,18 @@ def report_window(self): border.set_margin_bottom(20) # Create take screenshot button - self._screenshot_button = KanoButton("TAKE SCREENSHOT", "blue") + self._screenshot_button = KanoButton(_("TAKE SCREENSHOT"), "blue") self._screenshot_button.set_sensitive(True) self._screenshot_button.connect("button_press_event", self.screenshot_clicked) # Create attach screenshot button - self._attach_button = KanoButton("ADD IMAGE", "blue") + self._attach_button = KanoButton(_("ADD IMAGE"), "blue") self._attach_button.set_sensitive(True) self._attach_button.connect("button_press_event", self.attach_clicked) # Create send button - self._send_button = KanoButton("SEND") + self._send_button = KanoButton(_("SEND")) self._send_button.set_sensitive(False) self._send_button.connect("button_press_event", self.send_feedback) self._send_button.pack_and_align() @@ -245,7 +245,7 @@ def attach_clicked(self, button=None, event=None): ''' screenshot = None # Open file manager - dialog = Gtk.FileChooserDialog("Please choose a file", self, + dialog = Gtk.FileChooserDialog(_("Please choose a file"), self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, @@ -270,7 +270,7 @@ def add_filters(self, dialog): ''' # Image filter filter_images = Gtk.FileFilter() - filter_images.set_name("Images") + filter_images.set_name(_("Images")) filter_images.add_mime_type("image/png") filter_images.add_mime_type("image/jpeg") filter_images.add_mime_type("image/gif") @@ -283,7 +283,7 @@ def add_filters(self, dialog): # Any file filter filter_any = Gtk.FileFilter() - filter_any.set_name("Any files") + filter_any.set_name(_("Any files")) filter_any.add_pattern("*") dialog.add_filter(filter_any) @@ -350,7 +350,7 @@ def show_screenshot(self, widget, event): height * 0.5) image = Gtk.Image.new_from_pixbuf(pixbuf) - dialog = KanoDialog("Screenshot", widget=image) + dialog = KanoDialog(_("Screenshot"), widget=image) dialog.run() def pack_screenshot_buttons(self): diff --git a/kano_feedback/MainWindow.py b/kano_feedback/MainWindow.py index 3362c9c..00b8123 100644 --- a/kano_feedback/MainWindow.py +++ b/kano_feedback/MainWindow.py @@ -54,19 +54,19 @@ def send_feedback(self, button=None, event=None, body_title=None): return if self.bug_report: - title = "Important" + title = _("Important") description = ( - "Your feedback will include debugging information.\n" - "Do you want to continue?" + _("Your feedback will include debugging information.\n" +\ + "Do you want to continue?") ) kdialog = KanoDialog( title, description, { - "CANCEL": + _("CANCEL"): { "return_value": 1 }, - "OK": + _("OK"): { "return_value": 0 } @@ -86,35 +86,35 @@ def send_feedback(self, button=None, event=None, body_title=None): self._text.set_sensitive(False) def lengthy_process(): - button_dict = {"OK": {"return_value": self.CLOSE_FEEDBACK}} + button_dict = {_("OK"): {"return_value": self.CLOSE_FEEDBACK}} if not is_internet(): - title = "No internet connection" - description = "Configure your connection" - button_dict = {"OK": {"return_value": self.LAUNCH_WIFI}} + title = _("No internet connection") + description = _("Configure your connection") + button_dict = {_("OK"): {"return_value": self.LAUNCH_WIFI}} else: success, error = self.send_user_info(body_title=body_title) if success: - title = "Info" - description = "Feedback sent correctly" + title = _("Info") + description = _("Feedback sent correctly") button_dict = \ { - "OK": + _("OK"): { "return_value": self.CLOSE_FEEDBACK } } else: - title = "Info" - description = "Something went wrong, error: {}".format(error) + title = _("Info") + description = _("Something went wrong, error: {}").format(error) button_dict = \ { - "CLOSE FEEDBACK": + _("CLOSE FEEDBACK"): { "return_value": self.CLOSE_FEEDBACK, "color": "red" }, - "TRY AGAIN": + _("TRY AGAIN"): { "return_value": self.KEEP_OPEN, "color": "green" diff --git a/kano_feedback/WidgetWindow.py b/kano_feedback/WidgetWindow.py index cab121c..d289d3a 100644 --- a/kano_feedback/WidgetWindow.py +++ b/kano_feedback/WidgetWindow.py @@ -34,7 +34,7 @@ class WidgetWindow(ApplicationWindow): WIDTH = 500 HEIGHT_COMPACT = 50 HEIGHT_EXPANDED = 200 - SUBJECT = 'Kano Desktop Feedback Widget' + SUBJECT = _('Kano Desktop Feedback Widget') def __init__(self): ApplicationWindow.__init__(self, 'widget', self.WIDTH, @@ -104,7 +104,7 @@ def _initialise_window(self): self.app_name_opened = 'feedback-widget-opened' self.typeahead = None - self.help_tip_message = 'Type your feedback here!' + self.help_tip_message = _('Type your feedback here!') self.rotating_mode = True self.in_submit = False @@ -183,7 +183,7 @@ def _initialise_window(self): self._pack_input_widget() - self._send = send = OrangeButton('SEND') + self._send = send = OrangeButton(_('SEND')) apply_styling_to_widget(send.label, media_dir() + 'css/widget.css') send.set_sensitive(False) send.connect('clicked', self._send_clicked) diff --git a/lxpanel-plugin/kano_feedback.c b/lxpanel-plugin/kano_feedback.c index 2995006..35be5dd 100644 --- a/lxpanel-plugin/kano_feedback.c +++ b/lxpanel-plugin/kano_feedback.c @@ -21,6 +21,9 @@ #include +#include +#define _(str) gettext(str) + #define WIDGET_ICON "/usr/share/kano-feedback/media/icons/feedback-widget.png" #define CONTACT_ICON "/usr/share/kano-feedback/media/icons/Icon-Contact.png" #define SCREENSHOT_ICON "/usr/share/kano-feedback/media/icons/Icon-Report.png" @@ -45,6 +48,12 @@ static void menu_pos(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, static GtkWidget *plugin_constructor(LXPanel *panel, config_setting_t *settings) { + /* initialize i18n */ + setlocale(LC_MESSAGES,""); + setlocale(LC_CTYPE,""); + bindtextdomain("kano-toolset","/usr/share/locale"); + textdomain("kano-toolset"); + /* allocate our private structure instance */ kano_feedback_plugin_t *plugin = g_new0(kano_feedback_plugin_t, 1); plugin->panel = panel; @@ -151,19 +160,19 @@ static gboolean show_menu(GtkWidget *widget, GdkEventButton *event) gtk_widget_show(header_item); /* Contact button */ - GtkWidget* contact_item = gtk_image_menu_item_new_with_label("Contact Us"); + GtkWidget* contact_item = gtk_image_menu_item_new_with_label(_("Contact Us")); g_signal_connect(contact_item, "activate", G_CALLBACK(contact_clicked), NULL); gtk_menu_append(GTK_MENU(menu), contact_item); gtk_widget_show(contact_item); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(contact_item), get_resized_icon(CONTACT_ICON)); /* Knowledge button */ - GtkWidget* knowledge_item = gtk_image_menu_item_new_with_label("Help Center"); + GtkWidget* knowledge_item = gtk_image_menu_item_new_with_label(_("Help Center")); g_signal_connect(knowledge_item, "activate", G_CALLBACK(knowledge_clicked), NULL); gtk_menu_append(GTK_MENU(menu), knowledge_item); gtk_widget_show(knowledge_item); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(knowledge_item), get_resized_icon(KNOWLEDGE_ICON)); /* Screenshot button */ - GtkWidget* screenshot_item = gtk_image_menu_item_new_with_label("Report a Problem"); + GtkWidget* screenshot_item = gtk_image_menu_item_new_with_label(_("Report a Problem")); g_signal_connect(screenshot_item, "activate", G_CALLBACK(screenshot_clicked), NULL); gtk_menu_append(GTK_MENU(menu), screenshot_item); gtk_widget_show(screenshot_item); diff --git a/po/Makefile b/po/Makefile new file mode 100644 index 0000000..ae75f70 --- /dev/null +++ b/po/Makefile @@ -0,0 +1,38 @@ +APPNAME=kano-feedback +ORG="Kano Computing Ltd." + +MSGLANGS=$(notdir $(wildcard *po)) +MSGOBJS=$(addprefix ../locale/,$(MSGLANGS:.po=/LC_MESSAGES/$(APPNAME).mo)) + +.PHONY: clean_locales messages + +build: $(MSGOBJS) + +update: $(MSGLANGS) + +clean_locales: + rm -rf ../locale + +clean: clean_locales + rm -f messages.pot + +define run-xgettext +xgettext -f PYPOTFILES -L Python --force-po -o messages.pot \ + --package-name=$(APPNAME) --copyright-holder=$(ORG) +xgettext -j -f POTFILES -L C -k_ -o messages.pot \ + --package-name=$(APPNAME) --copyright-holder=$(ORG) +endef + +messages: + $(run-xgettext) + +messages.pot: + $(run-xgettext) + +%.po: messages.pot + msgmerge -N -U $*.po messages.pot + touch $*.po + +../locale/%/LC_MESSAGES/$(APPNAME).mo: clean_locales + mkdir -p $(dir $@) + msgfmt -c -o $@ $*.po diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 0000000..d00575e --- /dev/null +++ b/po/POTFILES @@ -0,0 +1 @@ +../lxpanel-plugin/kano_feedback.c diff --git a/po/PYPOTFILES b/po/PYPOTFILES new file mode 100644 index 0000000..4bfff97 --- /dev/null +++ b/po/PYPOTFILES @@ -0,0 +1,6 @@ +../kano_feedback/DataSender.py +../kano_feedback/FeedbackWindow.py +../kano_feedback/MainWindow.py +../kano_feedback/WidgetWindow.py +../lxpanel-plugin/kano_feedback.c + diff --git a/po/ja.po b/po/ja.po new file mode 100644 index 0000000..1599183 --- /dev/null +++ b/po/ja.po @@ -0,0 +1,150 @@ +# Japanese translations for kano-feedback package +# kano-feedback パッケージに対する英訳. +# Copyright (C) 2016 Kano Computing Ltd. +# This file is distributed under the same license as the kano-feedback package. +# Choppin Antoine , 2016. +# +msgid "" +msgstr "" +"Project-Id-Version: kano-feedback\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-07-17 20:29+0900\n" +"PO-Revision-Date: 2016-07-17 10:41+0900\n" +"Last-Translator: Choppin Antoine \n" +"Language-Team: Japanese\n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#: ../kano_feedback/DataSender.py:448 +msgid "Thank you" +msgstr "ありがとうございます" + +#: ../kano_feedback/DataSender.py:449 +msgid "We will use your feedback to improve your experience" +msgstr "いただいたフィードバックを活かして、改善していきます" + +#: ../kano_feedback/DataSender.py:484 +msgid "Unable to send" +msgstr "送信に失敗しました" + +#: ../kano_feedback/DataSender.py:485 +msgid "Error while sending your feedback. Do you want to retry?" +msgstr "フィードバックを送信できませんでした。再送してみますか?" + +#: ../kano_feedback/DataSender.py:488 +msgid "Close feedback" +msgstr "フィードバックを閉じる" + +#: ../kano_feedback/DataSender.py:493 +msgid "Retry" +msgstr "再試" + +#: ../kano_feedback/FeedbackWindow.py:25 ../kano_feedback/WidgetWindow.py:37 +msgid "Kano Desktop Feedback Widget" +msgstr "Kanoデスクトップフィードバックウィジェット" + +#: ../kano_feedback/FeedbackWindow.py:41 ../kano_feedback/FeedbackWindow.py:57 +#: ../lxpanel-plugin/kano_feedback.c:163 +msgid "Contact Us" +msgstr "お問い合わせ" + +#: ../kano_feedback/FeedbackWindow.py:70 ../kano_feedback/WidgetWindow.py:107 +msgid "Type your feedback here!" +msgstr "ご意見をここに書いてください!" + +#: ../kano_feedback/FeedbackWindow.py:124 +#: ../kano_feedback/FeedbackWindow.py:137 ../lxpanel-plugin/kano_feedback.c:175 +msgid "Report a Problem" +msgstr "問題を報告する" + +#: ../kano_feedback/FeedbackWindow.py:144 +msgid "Add subject (optional)" +msgstr "件名を入力(任意)" + +#: ../kano_feedback/FeedbackWindow.py:158 +msgid "Type your problem here!" +msgstr "問題をここに書いてください!" + +#: ../kano_feedback/FeedbackWindow.py:185 +msgid "TAKE SCREENSHOT" +msgstr "スクリーンショットを撮る" + +#: ../kano_feedback/FeedbackWindow.py:191 +msgid "ADD IMAGE" +msgstr "画像を添付する" + +#: ../kano_feedback/FeedbackWindow.py:196 ../kano_feedback/WidgetWindow.py:186 +msgid "SEND" +msgstr "送信" + +#: ../kano_feedback/FeedbackWindow.py:248 +msgid "Please choose a file" +msgstr "ファイルをお選びください" + +#: ../kano_feedback/FeedbackWindow.py:273 +msgid "Images" +msgstr "画像" + +#: ../kano_feedback/FeedbackWindow.py:286 +msgid "Any files" +msgstr "全てのファイル" + +#: ../kano_feedback/FeedbackWindow.py:353 +msgid "Screenshot" +msgstr "スクリーンショット" + +#: ../kano_feedback/MainWindow.py:57 +msgid "Important" +msgstr "重要" + +#: ../kano_feedback/MainWindow.py:59 +msgid "" +"Your feedback will include debugging information.\n" +"Do you want to continue?" +msgstr "" +"送信されるフィードバックにデバッグ情報が含まれます。\n" +"続けますか?" + +#: ../kano_feedback/MainWindow.py:65 +msgid "CANCEL" +msgstr "取り消し" + +#: ../kano_feedback/MainWindow.py:69 ../kano_feedback/MainWindow.py:89 +#: ../kano_feedback/MainWindow.py:94 ../kano_feedback/MainWindow.py:102 +msgid "OK" +msgstr "了解" + +#: ../kano_feedback/MainWindow.py:92 +msgid "No internet connection" +msgstr "インスタントに接続していません" + +#: ../kano_feedback/MainWindow.py:93 +msgid "Configure your connection" +msgstr "接続を設定してください" + +#: ../kano_feedback/MainWindow.py:98 ../kano_feedback/MainWindow.py:108 +msgid "Info" +msgstr "報告" + +#: ../kano_feedback/MainWindow.py:99 +msgid "Feedback sent correctly" +msgstr "フィードバックは無事に送信されました" + +#: ../kano_feedback/MainWindow.py:109 +msgid "Something went wrong, error: {}" +msgstr "エラーが発生しました: {}" + +#: ../kano_feedback/MainWindow.py:112 +msgid "CLOSE FEEDBACK" +msgstr "フィードバックを閉じる" + +#: ../kano_feedback/MainWindow.py:117 +msgid "TRY AGAIN" +msgstr "やり直し" + +#: ../lxpanel-plugin/kano_feedback.c:169 +msgid "Help Center" +msgstr "ヘルプセンター" From 1fa060eec0a2eb85899d34d8812d3479571f0e22 Mon Sep 17 00:00:00 2001 From: Antoine Choppin Date: Sun, 17 Jul 2016 21:01:51 +0900 Subject: [PATCH 2/3] Fix gettext domain --- bin/kano-feedback | 2 +- lxpanel-plugin/kano_feedback.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/kano-feedback b/bin/kano-feedback index b3c6d5c..9d6c818 100755 --- a/bin/kano-feedback +++ b/bin/kano-feedback @@ -21,7 +21,7 @@ if __name__ == '__main__' and __package__ is None: locale_path = None import kano_i18n.init -kano_i18n.init.install('kano-toolset', locale_path) +kano_i18n.init.install('kano-feedback', locale_path) from kano_feedback.FeedbackWindow import FeedbackWindow diff --git a/lxpanel-plugin/kano_feedback.c b/lxpanel-plugin/kano_feedback.c index 35be5dd..3988890 100644 --- a/lxpanel-plugin/kano_feedback.c +++ b/lxpanel-plugin/kano_feedback.c @@ -51,8 +51,8 @@ static GtkWidget *plugin_constructor(LXPanel *panel, config_setting_t *settings) /* initialize i18n */ setlocale(LC_MESSAGES,""); setlocale(LC_CTYPE,""); - bindtextdomain("kano-toolset","/usr/share/locale"); - textdomain("kano-toolset"); + bindtextdomain("kano-feedback","/usr/share/locale"); + textdomain("kano-feedback"); /* allocate our private structure instance */ kano_feedback_plugin_t *plugin = g_new0(kano_feedback_plugin_t, 1); From 7b6489ddf3ab3adea654bf9141780717c1700804 Mon Sep 17 00:00:00 2001 From: Antoine Choppin Date: Mon, 18 Jul 2016 17:05:54 +0900 Subject: [PATCH 3/3] Fix lxplugin and add missing translations --- debian/install | 3 +++ kano_feedback/FeedbackWindow.py | 2 +- lxpanel-plugin/kano_feedback.c | 7 +++---- po/ja.po | 21 +++++++++++++-------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/debian/install b/debian/install index 08e680e..776f335 100644 --- a/debian/install +++ b/debian/install @@ -12,3 +12,6 @@ icon/feedback.png /usr/share/icons/Kano/66x66/apps/ icon/kano-help.png /usr/share/icons/Kano/88x88/apps/ lxpanel-plugin/kano_feedback.so usr/lib/arm-linux-gnueabihf/lxpanel/plugins/ + +locale/* usr/share/locale/ + diff --git a/kano_feedback/FeedbackWindow.py b/kano_feedback/FeedbackWindow.py index 2559066..56a4a2c 100644 --- a/kano_feedback/FeedbackWindow.py +++ b/kano_feedback/FeedbackWindow.py @@ -94,7 +94,7 @@ def contact_window(self): border.set_margin_bottom(20) # Create send button - self._send_button = KanoButton("SEND") + self._send_button = KanoButton(_("SEND")) self._send_button.set_sensitive(False) self._send_button.connect("button_press_event", self.send_feedback) self._send_button.pack_and_align() diff --git a/lxpanel-plugin/kano_feedback.c b/lxpanel-plugin/kano_feedback.c index 3988890..bbdb8f1 100644 --- a/lxpanel-plugin/kano_feedback.c +++ b/lxpanel-plugin/kano_feedback.c @@ -22,7 +22,7 @@ #include #include -#define _(str) gettext(str) +#include #define WIDGET_ICON "/usr/share/kano-feedback/media/icons/feedback-widget.png" #define CONTACT_ICON "/usr/share/kano-feedback/media/icons/Icon-Contact.png" @@ -49,8 +49,7 @@ static void menu_pos(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, static GtkWidget *plugin_constructor(LXPanel *panel, config_setting_t *settings) { /* initialize i18n */ - setlocale(LC_MESSAGES,""); - setlocale(LC_CTYPE,""); + setlocale(LC_ALL, ""); bindtextdomain("kano-feedback","/usr/share/locale"); textdomain("kano-feedback"); @@ -154,7 +153,7 @@ static gboolean show_menu(GtkWidget *widget, GdkEventButton *event) return FALSE; /* Create the menu items */ - header_item = gtk_menu_item_new_with_label("Help"); + header_item = gtk_menu_item_new_with_label(_("Help")); gtk_widget_set_sensitive(header_item, FALSE); gtk_menu_append(GTK_MENU(menu), header_item); gtk_widget_show(header_item); diff --git a/po/ja.po b/po/ja.po index 1599183..7aad90d 100644 --- a/po/ja.po +++ b/po/ja.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: kano-feedback\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-07-17 20:29+0900\n" +"POT-Creation-Date: 2016-07-18 17:04+0900\n" "PO-Revision-Date: 2016-07-17 10:41+0900\n" "Last-Translator: Choppin Antoine \n" "Language-Team: Japanese\n" @@ -47,7 +47,7 @@ msgid "Kano Desktop Feedback Widget" msgstr "Kanoデスクトップフィードバックウィジェット" #: ../kano_feedback/FeedbackWindow.py:41 ../kano_feedback/FeedbackWindow.py:57 -#: ../lxpanel-plugin/kano_feedback.c:163 +#: ../lxpanel-plugin/kano_feedback.c:162 msgid "Contact Us" msgstr "お問い合わせ" @@ -55,8 +55,13 @@ msgstr "お問い合わせ" msgid "Type your feedback here!" msgstr "ご意見をここに書いてください!" +#: ../kano_feedback/FeedbackWindow.py:97 ../kano_feedback/FeedbackWindow.py:196 +#: ../kano_feedback/WidgetWindow.py:186 +msgid "SEND" +msgstr "送信" + #: ../kano_feedback/FeedbackWindow.py:124 -#: ../kano_feedback/FeedbackWindow.py:137 ../lxpanel-plugin/kano_feedback.c:175 +#: ../kano_feedback/FeedbackWindow.py:137 ../lxpanel-plugin/kano_feedback.c:174 msgid "Report a Problem" msgstr "問題を報告する" @@ -76,10 +81,6 @@ msgstr "スクリーンショットを撮る" msgid "ADD IMAGE" msgstr "画像を添付する" -#: ../kano_feedback/FeedbackWindow.py:196 ../kano_feedback/WidgetWindow.py:186 -msgid "SEND" -msgstr "送信" - #: ../kano_feedback/FeedbackWindow.py:248 msgid "Please choose a file" msgstr "ファイルをお選びください" @@ -145,6 +146,10 @@ msgstr "フィードバックを閉じる" msgid "TRY AGAIN" msgstr "やり直し" -#: ../lxpanel-plugin/kano_feedback.c:169 +#: ../lxpanel-plugin/kano_feedback.c:156 +msgid "Help" +msgstr "ヘルプ" + +#: ../lxpanel-plugin/kano_feedback.c:168 msgid "Help Center" msgstr "ヘルプセンター"