]> git.mdlowis.com Git - proto/labwc.git/commitdiff
nls: add native language support
author01micko <01micko@gmail.com>
Sun, 1 May 2022 04:38:45 +0000 (14:38 +1000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 2 May 2022 09:33:42 +0000 (10:33 +0100)
- adds labwc.pot and po files for de, es, it and sv
- added notes in NEWS.md and CONTRIBUTING.md
- addresses #269
- conditional upon `msgfmt` being installed
- can be disabled at build time

15 files changed:
CONTRIBUTING.md
NEWS.md
include/labwc.h
meson.build
meson_options.txt
po/LINGUAS [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
po/de.po [new file with mode: 0644]
po/es.po [new file with mode: 0644]
po/it.po [new file with mode: 0644]
po/labwc.pot [new file with mode: 0644]
po/meson.build [new file with mode: 0644]
po/sv.po [new file with mode: 0644]
src/main.c
src/menu/menu.c

index 139edf1f4d24cba5c42cccf81d4791589c9038e2..00838753ea9b05cbac0f6f14fef1f9824fe9d242 100644 (file)
@@ -30,8 +30,12 @@ line with wlroots.
 With the introduction of the scene-graph API, some wlroots functions also use
 node coordinates (nx, ny) but we prefer (sx, sy) where possible.
 
+## Native Language Support
+
+Translators can add their `MY_LOCALE.po` files to the `po` directory
+based on `po/labwc.pot` and issue a pull request.
+
 
 [coding style]: https://git.sr.ht/~sircmpwn/cstyle
 [commit messages]: https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/CONTRIBUTING.md#commit-messages 
 [checkpatch.pl]: https://github.com/johanmalm/checkpatch.pl
-
diff --git a/NEWS.md b/NEWS.md
index f429ef861572af52fcf08e1c7cb0504e88ba4f13..44aa02f183e2b7c662c166851aed33e1e82a659b 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -27,7 +27,8 @@ that branch.
 This release contains significant refactoring to use the wlroots
 scene-graph API, particularly src/output.c, server-side-decoration
 and the layer-shell implementation. Many thanks to @Consolatis for some
-heavy lifting with this.
+heavy lifting with this. Native language support has been added by
+@01micko.
 
 ### Added
 
index f6430a888e88795352de97a272ebef59ac56464c..a06b7d4824c9646ed05f0a20c440581126390efa 100644 (file)
 #include "config/keybind.h"
 #include "config/rcxml.h"
 #include "ssd.h"
+#if HAVE_NLS
+#include <libintl.h>
+#include <locale.h>
+#define _ gettext
+#else
+#define _(s) (s)
+#endif
 
 #define XCURSOR_DEFAULT "left_ptr"
 #define XCURSOR_SIZE 24
index 9cd11810c791aded5734d89f92b13080f2fbce56..47413859ef2ed18a086959e45aa29e14fd86a835 100644 (file)
@@ -75,6 +75,15 @@ have_xwayland = xcb.found() and wlroots_has_xwayland
 conf_data = configuration_data()
 conf_data.set10('HAVE_XWAYLAND', have_xwayland)
 
+msgfmt = find_program('msgfmt', required: get_option('nls'))
+if msgfmt.found()
+  source_root = meson.current_source_dir()
+  conf_data.set('HAVE_NLS', 1)
+  subdir('po')
+else
+  conf_data.set('HAVE_NLS', 0)
+endif
+
 labwc_inc = include_directories('include')
 
 subdir('protocols')
index d64f510cad05904a6b80f0d0867f8a6d8f77ac25..00558f17ef628daa11a44d079de97c6bc7f5289d 100644 (file)
@@ -1,2 +1,3 @@
 option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
 option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications')
+option('nls', type: 'feature', value: 'auto', description: 'Enable native language support')
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644 (file)
index 0000000..c6a73c9
--- /dev/null
@@ -0,0 +1 @@
+de es it sv
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..ee1427e
--- /dev/null
@@ -0,0 +1 @@
+src/menu/menu.c
diff --git a/po/de.po b/po/de.po
new file mode 100644 (file)
index 0000000..20cc55a
--- /dev/null
+++ b/po/de.po
@@ -0,0 +1,50 @@
+# Labwc pot file
+# Copyright (C) 2022
+# This file is distributed under the same license as the labwc package.
+# FIRST AUTHOR <https://github.com/Consolatis>, 2022.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: labwc\n"
+"Report-Msgid-Bugs-To: https://github.com/labwc/labwc/issues\n"
+"POT-Creation-Date: 2022-04-30 16:43+1000\n"
+"PO-Revision-Date: 2022-04-30 16:50+1000\n"
+"Last-Translator: Consolatis <https://github.com/Consolatis>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: German\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/menu/menu.c:428
+msgid "Reconfigure"
+msgstr "Rekonfigurieren"
+
+#: src/menu/menu.c:430
+msgid "Exit"
+msgstr "Beenden"
+
+#: src/menu/menu.c:446
+msgid "Minimize"
+msgstr "Minimieren"
+
+#: src/menu/menu.c:448
+msgid "Maximize"
+msgstr "Maximieren"
+
+#: src/menu/menu.c:450
+msgid "Fullscreen"
+msgstr "Vollbild"
+
+#: src/menu/menu.c:452
+msgid "Decorations"
+msgstr "Dekorationen"
+
+#: src/menu/menu.c:454
+msgid "AlwaysOnTop"
+msgstr "Immer im Vordergrund"
+
+#: src/menu/menu.c:456
+msgid "Close"
+msgstr "Schließen"
diff --git a/po/es.po b/po/es.po
new file mode 100644 (file)
index 0000000..bc5390c
--- /dev/null
+++ b/po/es.po
@@ -0,0 +1,50 @@
+# Labwc pot file
+# Copyright (C) 2022
+# This file is distributed under the same license as the labwc package.
+# FIRST AUTHOR <01micko@gmail.com>, 2022.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: labwc\n"
+"Report-Msgid-Bugs-To: https://github.com/labwc/labwc/issues\n"
+"POT-Creation-Date: 2022-04-30 16:43+1000\n"
+"PO-Revision-Date: 2022-04-30 16:50+1000\n"
+"Last-Translator: Mick Amadio <01micko@gmail.com>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: Spanish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/menu/menu.c:428
+msgid "Reconfigure"
+msgstr "Reconfigurar"
+
+#: src/menu/menu.c:430
+msgid "Exit"
+msgstr "Salir"
+
+#: src/menu/menu.c:446
+msgid "Minimize"
+msgstr "Minimizar"
+
+#: src/menu/menu.c:448
+msgid "Maximize"
+msgstr "Maximizar"
+
+#: src/menu/menu.c:450
+msgid "Fullscreen"
+msgstr "Pantalla completa"
+
+#: src/menu/menu.c:452
+msgid "Decorations"
+msgstr "Decoraciones"
+
+#: src/menu/menu.c:454
+msgid "AlwaysOnTop"
+msgstr "Siempre encima"
+
+#: src/menu/menu.c:456
+msgid "Close"
+msgstr "Cerrar"
diff --git a/po/it.po b/po/it.po
new file mode 100644 (file)
index 0000000..0e5da4b
--- /dev/null
+++ b/po/it.po
@@ -0,0 +1,50 @@
+# Labwc pot file
+# Copyright (C) 2022
+# This file is distributed under the same license as the labwc package.
+# FIRST AUTHOR <01micko@gmail.com>, 2022.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: labwc\n"
+"Report-Msgid-Bugs-To: https://github.com/labwc/labwc/issues\n"
+"POT-Creation-Date: 2022-04-30 16:43+1000\n"
+"PO-Revision-Date: 2022-04-30 16:50+1000\n"
+"Last-Translator: Mick Amadio <01micko@gmail.com>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: Italian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/menu/menu.c:428
+msgid "Reconfigure"
+msgstr "Riconfigurare"
+
+#: src/menu/menu.c:430
+msgid "Exit"
+msgstr "Uscita"
+
+#: src/menu/menu.c:446
+msgid "Minimize"
+msgstr "Riduci"
+
+#: src/menu/menu.c:448
+msgid "Maximize"
+msgstr "Ingrandisci"
+
+#: src/menu/menu.c:450
+msgid "Fullscreen"
+msgstr "Schermo intero"
+
+#: src/menu/menu.c:452
+msgid "Decorations"
+msgstr "Decorazioni"
+
+#: src/menu/menu.c:454
+msgid "AlwaysOnTop"
+msgstr "Sempre sopra"
+
+#: src/menu/menu.c:456
+msgid "Close"
+msgstr "Chiudi"
diff --git a/po/labwc.pot b/po/labwc.pot
new file mode 100644 (file)
index 0000000..b355c0c
--- /dev/null
@@ -0,0 +1,50 @@
+# Labwc pot file
+# Copyright (C) 2022
+# This file is distributed under the same license as the labwc package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: labwc\n"
+"Report-Msgid-Bugs-To: https://github.com/labwc/labwc/issues\n"
+"POT-Creation-Date: 2022-04-30 16:43+1000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/menu/menu.c:428
+msgid "Reconfigure"
+msgstr ""
+
+#: src/menu/menu.c:430
+msgid "Exit"
+msgstr ""
+
+#: src/menu/menu.c:446
+msgid "Minimize"
+msgstr ""
+
+#: src/menu/menu.c:448
+msgid "Maximize"
+msgstr ""
+
+#: src/menu/menu.c:450
+msgid "Fullscreen"
+msgstr ""
+
+#: src/menu/menu.c:452
+msgid "Decorations"
+msgstr ""
+
+#: src/menu/menu.c:454
+msgid "AlwaysOnTop"
+msgstr ""
+
+#: src/menu/menu.c:456
+msgid "Close"
+msgstr ""
diff --git a/po/meson.build b/po/meson.build
new file mode 100644 (file)
index 0000000..d6e1ff3
--- /dev/null
@@ -0,0 +1,12 @@
+i18n = import('i18n')
+add_project_arguments('-DGETTEXT_PACKAGE="' + meson.project_name() + '"',
+  '-DLOCALEDIR="' + get_option('prefix') / get_option('localedir') + '"',
+  language:'c')
+i18n.gettext(meson.project_name(),
+  args: ['--directory=' + source_root,
+    '--add-comments=TRANSLATORS',
+    '--no-location',
+    '--keyword=_',
+    '--msgid-bugs=https://github.com/labwc/labwc/issues'],
+    preset: 'glib'
+)
diff --git a/po/sv.po b/po/sv.po
new file mode 100644 (file)
index 0000000..db24ab5
--- /dev/null
+++ b/po/sv.po
@@ -0,0 +1,50 @@
+# Labwc pot file
+# Copyright (C) 2022
+# This file is distributed under the same license as the labwc package.
+# FIRST AUTHOR <jgm323@gmail.com>, 2022.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: labwc\n"
+"Report-Msgid-Bugs-To: https://github.com/labwc/labwc/issues\n"
+"POT-Creation-Date: 2022-04-30 16:43+1000\n"
+"PO-Revision-Date: 2022-04-30 16:50+1000\n"
+"Last-Translator: Johan Malm <jgm323@gmail.com\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: Swedish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/menu/menu.c:428
+msgid "Reconfigure"
+msgstr "Konfigurera om"
+
+#: src/menu/menu.c:430
+msgid "Exit"
+msgstr "Utgång"
+
+#: src/menu/menu.c:446
+msgid "Minimize"
+msgstr "Minimera"
+
+#: src/menu/menu.c:448
+msgid "Maximize"
+msgstr "Maximera"
+
+#: src/menu/menu.c:450
+msgid "Fullscreen"
+msgstr "Fullskärm"
+
+#: src/menu/menu.c:452
+msgid "Decorations"
+msgstr "Dekorationer"
+
+#: src/menu/menu.c:454
+msgid "AlwaysOnTop"
+msgstr "Alltid överst"
+
+#: src/menu/menu.c:456
+msgid "Close"
+msgstr "Stäng"
index 3ee2b6efd7acd1e040b5bc5d5b98f79b3af28223..1e2dc1eef95a7a1a2daa4028dbcb7b202190dd5b 100644 (file)
@@ -32,6 +32,11 @@ usage(void)
 int
 main(int argc, char *argv[])
 {
+#if HAVE_NLS
+       setlocale(LC_ALL, "");
+       bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+       textdomain(GETTEXT_PACKAGE);
+#endif
        char *startup_cmd = NULL;
        char *config_file = NULL;
        enum wlr_log_importance verbosity = WLR_ERROR;
index b23fcbcb43541fcd6368e16903bb27ee87f08021..8bfb29f23a8910d89ccc34088ab2d233f74bb444 100644 (file)
@@ -425,9 +425,9 @@ menu_init_rootmenu(struct server *server)
                menu = menu_create(server, "root-menu", "");
        }
        if (wl_list_empty(&menu->menuitems)) {
-               current_item = item_create(menu, "Reconfigure");
+               current_item = item_create(menu, _("Reconfigure"));
                fill_item("name.action", "Reconfigure");
-               current_item = item_create(menu, "Exit");
+               current_item = item_create(menu, _("Exit"));
                fill_item("name.action", "Exit");
        }
 }
@@ -443,17 +443,17 @@ menu_init_windowmenu(struct server *server)
                menu = menu_create(server, "client-menu", "");
        }
        if (wl_list_empty(&menu->menuitems)) {
-               current_item = item_create(menu, "Minimize");
+               current_item = item_create(menu, _("Minimize"));
                fill_item("name.action", "Iconify");
-               current_item = item_create(menu, "Maximize");
+               current_item = item_create(menu, _("Maximize"));
                fill_item("name.action", "ToggleMaximize");
-               current_item = item_create(menu, "Fullscreen");
+               current_item = item_create(menu, _("Fullscreen"));
                fill_item("name.action", "ToggleFullscreen");
-               current_item = item_create(menu, "Decorations");
+               current_item = item_create(menu, _("Decorations"));
                fill_item("name.action", "ToggleDecorations");
-               current_item = item_create(menu, "AlwaysOnTop");
+               current_item = item_create(menu, _("AlwaysOnTop"));
                fill_item("name.action", "ToggleAlwaysOnTop");
-               current_item = item_create(menu, "Close");
+               current_item = item_create(menu, _("Close"));
                fill_item("name.action", "Close");
        }
 }