From 964f1da305d40825535bdfa67e8124c78c80b051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 3 Dec 2021 18:57:59 +0100 Subject: [PATCH 1/6] Initialize gettext --- meson.build | 8 ++++++-- po/LINGUAS | 0 po/POTFILES.in | 1 + po/meson.build | 2 ++ src/config.h.in | 6 ++++++ src/server-main.c | 4 ++++ 6 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 po/LINGUAS create mode 100644 po/POTFILES.in create mode 100644 po/meson.build diff --git a/meson.build b/meson.build index 342eccaa..37a3499e 100644 --- a/meson.build +++ b/meson.build @@ -36,8 +36,6 @@ add_project_arguments( i18n = import('i18n') -conf_data = configuration_data() - if get_option('buildtype').startswith('debug') add_project_arguments('-DDEBUG=1', language : 'c') endif @@ -63,6 +61,7 @@ endif prefix = get_option('prefix') bindir = join_paths(prefix, get_option('bindir')) datadir = join_paths(prefix, get_option('datadir')) +localedir = join_paths(prefix, get_option('localedir')) desktopdir = join_paths(datadir, 'applications') pkgdatadir = join_paths(datadir, meson.project_name()) if get_option('depdatadir') == '' @@ -72,6 +71,10 @@ else endif dbusdir = join_paths(depdatadir, 'dbus-1/interfaces') +conf_data = configuration_data() +conf_data.set_quoted('GETTEXT_PACKAGE', 'squeekboard') +conf_data.set_quoted('LOCALEDIR', localedir) + summary = [ '', '------------------', @@ -114,6 +117,7 @@ cargo_script = find_program('cargo.sh') cargo_build = find_program('cargo_build.py') subdir('data') +subdir('po') subdir('protocols') subdir('src') subdir('tools') diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 00000000..e69de29b diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 00000000..3641d8d1 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1 @@ +data/popup.ui diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 00000000..897abe46 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,2 @@ +i18n = import('i18n') +i18n.gettext('squeekboard', preset : 'glib') diff --git a/src/config.h.in b/src/config.h.in index ae878778..d7afccff 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -2,3 +2,9 @@ * Autogenerated by the Meson build system. * Do not edit, your changes will be lost. */ + +#pragma once + +#mesondefine GETTEXT_PACKAGE + +#mesondefine LOCALEDIR diff --git a/src/server-main.c b/src/server-main.c index 55d2df04..32923e8a 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -326,6 +326,10 @@ main (int argc, char **argv) return 1; } + textdomain (GETTEXT_PACKAGE); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + if (!gtk_init_check (&argc, &argv)) { g_printerr ("Can't init GTK\n"); exit (1); From d696c9624e426a77516edd6328e9a0970b176ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 3 Dec 2021 18:58:01 +0100 Subject: [PATCH 2/6] Reuse the unused popover ui file for i18n Since the current code uses a handcoded approach for popup construction reuse the unused ui file to keep translatable strings. Since UI file in popover.rs runs through glib the strings get translated. Future rework will allow us to get rid of this duplication but since the ui file went unnoticed for so long who could possibly complain. Closes: #315 --- data/popup.ui | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/data/popup.ui b/data/popup.ui index 9e76694d..214fbea6 100644 --- a/data/popup.ui +++ b/data/popup.ui @@ -1,19 +1,12 @@ - + - - - False - - - True - False - vertical - - - main - 1 - - - + +
+ + Keyboard Settings + settings + +
+
From 74f55b30ef4ccce17cf7493ce1aa3fe83a14cfde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 3 Dec 2021 18:58:02 +0100 Subject: [PATCH 3/6] po: Add German translation --- po/LINGUAS | 1 + po/de.po | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 po/de.po diff --git a/po/LINGUAS b/po/LINGUAS index e69de29b..7673daa9 100644 --- a/po/LINGUAS +++ b/po/LINGUAS @@ -0,0 +1 @@ +de diff --git a/po/de.po b/po/de.po new file mode 100644 index 00000000..fba9fe73 --- /dev/null +++ b/po/de.po @@ -0,0 +1,22 @@ +# German translations for squeekboard package. +# Copyright (C) 2021 THE squeekboard'S COPYRIGHT HOLDER +# This file is distributed under the same license as the squeekboard package. +# Automatically generated, 2021. +# +msgid "" +msgstr "" +"Project-Id-Version: squeekboard\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-12-03 18:41+0100\n" +"PO-Revision-Date: 2021-12-03 18:41+0100\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: data/popup.ui:15 +msgid "Keyboard Settings" +msgstr "Tastatureinstellungen" From fdcef4aa882fe3b5af30663cbb7d1ab7729354e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 3 Dec 2021 19:00:22 +0100 Subject: [PATCH 4/6] gresources: Drop popup.ui It's unused in the code atm --- data/squeekboard.gresources.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/data/squeekboard.gresources.xml b/data/squeekboard.gresources.xml index 8e98c977..258dd295 100644 --- a/data/squeekboard.gresources.xml +++ b/data/squeekboard.gresources.xml @@ -3,7 +3,6 @@ style.css style-Adwaita:dark.css - popup.ui icons/key-enter.svg icons/key-shift.svg icons/keyboard-mode-symbolic.svg From 3306907008ce0b9bf3d29567338d1e4327cb838e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 4 Dec 2021 13:12:48 +0100 Subject: [PATCH 5/6] Revert "gresources: Drop popup.ui" This reverts commit fdcef4aa882fe3b5af30663cbb7d1ab7729354e1. --- data/squeekboard.gresources.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/data/squeekboard.gresources.xml b/data/squeekboard.gresources.xml index 258dd295..8e98c977 100644 --- a/data/squeekboard.gresources.xml +++ b/data/squeekboard.gresources.xml @@ -3,6 +3,7 @@ style.css style-Adwaita:dark.css + popup.ui icons/key-enter.svg icons/key-shift.svg icons/keyboard-mode-symbolic.svg From 0c4d3e545028fb6d5a5d3c9edeb959abbd9f6f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 5 Dec 2021 18:14:39 +0100 Subject: [PATCH 6/6] debian: Install translations --- debian/squeekboard.install | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/squeekboard.install b/debian/squeekboard.install index 7f2df323..801d057c 100644 --- a/debian/squeekboard.install +++ b/debian/squeekboard.install @@ -1,2 +1,3 @@ tools/squeekboard-restyled usr/bin usr/bin/squeekboard /usr/bin +usr/share/locale/