diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..e0d25c8 --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +# Language list must be in alphabetical order diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 0000000..cb6db2e --- /dev/null +++ b/po/POTFILES @@ -0,0 +1,19 @@ +data/org.freedesktop.TuhiGui.appdata.xml.in.in +data/org.freedesktop.TuhiGui.desktop.in + +data/ui/AboutDialog.ui.in +data/ui/Drawing.ui +data/ui/DrawingPerspective.ui +data/ui/ErrorPerspective.ui +data/ui/MainWindow.ui +data/ui/SetupPerspective.ui + +tuhigui/application.py +tuhigui/config.py +tuhigui/drawing.py +tuhigui/drawingperspective.py +tuhigui/errorperspective.py +tuhigui/setupdialog.py +tuhigui/svg.py +tuhigui/tuhi.py +tuhigui/window.py diff --git a/po/README.md b/po/README.md new file mode 100644 index 0000000..f49bfc0 --- /dev/null +++ b/po/README.md @@ -0,0 +1,37 @@ +i18n +==== + +This directory contains the translations of TuhiGui. + +For errors in translations, please [file an +issue](https://github.com/tuhiproject/tuhi/issues/new). + +New or updated translations are always welcome. To start a new translation, run: + + $ meson translation-build + $ ninja -C translation-build tuhigui-pot + # Now you can optionally remove the build directory + $ rm -rf translation-build + $ cp po/tuhigui.pot po/$lang.po + +where `$lang` is the language code of your target language, e.g. `nl` for Dutch +or `en_GB` for British English. Edit the +[LINGUAS](https://github.com/tuhiproject/tuhigui/blob/master/po/LINGUAS) file and +add your language code, keeping the list sorted alphabetically. Finally, open +the `.po` file you just created and translate all the strings. Don't forget to +fill in the information in the header! + +To update an existing translation, run: + + $ meson translation-build + $ ninja -C translation-build tuhigui-update-po + # Now you can optionally remove the build directory + $ rm -rf translation-build + +and update the `po/$lang.po` file of your target language. + +When you are done translating, file a pull request on +[GitHub](https://github.com/tuhiproject/tuhi) or, if you don't know how to, [open +an issue](https://github.com/tuhiproject/tuhi/issues/new) and attach the `.po` +file there. + diff --git a/tuhigui/drawing.py b/tuhigui/drawing.py index a9ba93e..2fbe4b1 100644 --- a/tuhigui/drawing.py +++ b/tuhigui/drawing.py @@ -10,6 +10,8 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # + +from gettext import gettext as _ from gi.repository import GObject, Gtk from .config import Config @@ -27,9 +29,9 @@ def relative_date(timestamp): diff = t - today if diff.days == 0: - return 'Today' + return _('Today') if diff.days == -1: - return 'Yesterday' + return _('Yesterday') if diff.days > -4: # last 4 days we convert to weekdays return t.strftime('%A') @@ -68,20 +70,23 @@ class Drawing(Gtk.Box): @Gtk.Template.Callback('_on_download_button_clicked') def _on_download_button_clicked(self, button): - dialog = Gtk.FileChooserDialog('Please choose a file', + dialog = Gtk.FileChooserDialog(_('Please choose a file'), None, Gtk.FileChooserAction.SAVE, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK)) dialog.set_do_overwrite_confirmation(True) - dialog.set_current_name('untitled.svg') + # Translators: the default filename to save to + dialog.set_current_name(_('untitled.svg')) filter_any = Gtk.FileFilter() - filter_any.set_name('Any files') + # Translators: filter name to show all/any files + filter_any.set_name(_('Any files')) filter_any.add_pattern('*') filter_svg = Gtk.FileFilter() - filter_svg.set_name('SVG files') + # Translators: filter to show svg files only + filter_svg.set_name(_('SVG files')) filter_svg.add_pattern('*.svg') dialog.add_filter(filter_svg) dialog.add_filter(filter_any) diff --git a/tuhigui/drawingperspective.py b/tuhigui/drawingperspective.py index 8ffd3f8..6996dfe 100644 --- a/tuhigui/drawingperspective.py +++ b/tuhigui/drawingperspective.py @@ -11,6 +11,7 @@ # GNU General Public License for more details. # +from gettext import gettext as _ from gi.repository import GObject, Gtk from .drawing import Drawing from .config import Config @@ -32,19 +33,22 @@ def relative_time(seconds): WEEK = 7 * DAY if seconds < 30: - return 'just now' + return _('just now') if seconds < 5 * MIN: - return 'a few minutes ago' + return _('a few minutes ago') if seconds < H: - return f'{int(seconds/MIN/10) * 10} minutes ago' + minutes = int(seconds / MIN / 10) * 10 + return _(f'{minutes} minutes ago') if seconds < DAY: - return f'{int(seconds/H)} hours ago' + hours = int(seconds / H) + return _(f'{hours} hours ago') if seconds < 4 * WEEK: - return f'{int(seconds/DAY)} days ago' + days = int(seconds / DAY) + return _(f'{days} days ago') if seconds > 10 * 365 * DAY: - return 'never' + return _('never') - return 'a long time ago' + return _('a long time ago') @Gtk.Template(resource_path="/org/freedesktop/TuhiGui/ui/DrawingPerspective.ui") diff --git a/tuhigui/setupdialog.py b/tuhigui/setupdialog.py index 4a87357..e597795 100644 --- a/tuhigui/setupdialog.py +++ b/tuhigui/setupdialog.py @@ -11,6 +11,7 @@ # GNU General Public License for more details. # +from gettext import gettext as _ from gi.repository import GObject, Gtk import gi @@ -39,7 +40,7 @@ class SetupDialog(Gtk.Dialog): def _on_unregistered_device(self, tuhi, device): tuhi.disconnect(self._sig) - self.label_devicename_p1.set_text(f'Connecting to {device.name}') + self.label_devicename_p1.set_text(_(f'Connecting to {device.name}')) self.stack.set_visible_child_name('page1') self._sig = device.connect('button-press-required', self._on_button_press_required) device.register() diff --git a/tuhigui/window.py b/tuhigui/window.py index d2b87fb..f27b61a 100644 --- a/tuhigui/window.py +++ b/tuhigui/window.py @@ -32,23 +32,23 @@ MENU_XML = """