diff --git a/README.md b/README.md index 3f30cd510..df66a1392 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Install dependencies: * wayland * wayland-protocols \* * libxkbcommon +* xkeyboard-config * cairo * gdk-pixbuf2 \*\* * pam (optional) diff --git a/main.c b/main.c index 2624f7438..df00d96d7 100644 --- a/main.c +++ b/main.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "background-image.h" #include "cairo.h" #include "comm.h" @@ -1101,6 +1103,10 @@ int main(int argc, char **argv) { initialize_pw_backend(argc, argv); srand(time(NULL)); + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + textdomain(GETTEXT_PACKAGE); + enum line_mode line_mode = LM_LINE; state.failed_attempts = 0; state.args = (struct swaylock_args){ diff --git a/meson.build b/meson.build index 62c188aa6..558b37e65 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( 'c', version: '1.6', license: 'MIT', - meson_version: '>=0.48.0', + meson_version: '>=0.50.0', default_options: [ 'c_std=c11', 'warning_level=2', @@ -27,6 +27,8 @@ sysconfdir = get_option('sysconfdir') prefix = get_option('prefix') is_freebsd = host_machine.system().startswith('freebsd') +subdir('po') + add_project_arguments( '-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'c') @@ -38,6 +40,7 @@ endif wayland_client = dependency('wayland-client') wayland_protos = dependency('wayland-protocols', version: '>=1.14') xkbcommon = dependency('xkbcommon') +xkeyboard_config = dependency('xkeyboard-config') cairo = dependency('cairo') gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf')) bash_comp = dependency('bash-completion', required: false) diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 000000000..d7609b1d8 --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +de fr diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 000000000..74188732e --- /dev/null +++ b/po/POTFILES @@ -0,0 +1 @@ +render.c diff --git a/po/de.po b/po/de.po new file mode 100644 index 000000000..50480562b --- /dev/null +++ b/po/de.po @@ -0,0 +1,34 @@ +# German translations for swaylock package. +# Copyright (C) 2020 THE swaylock'S COPYRIGHT HOLDER +# This file is distributed under the same license as the swaylock package. +# Automatically generated, 2020. +# +msgid "" +msgstr "" +"Project-Id-Version: swaylock 1.6\n" +"Report-Msgid-Bugs-To: https://github.com/swaywm/swaylock/issues\n" +"POT-Creation-Date: 2020-08-18 14:46+0200\n" +"PO-Revision-Date: 2020-08-18 15:25+0200\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: render.c:161 +msgid "verifying" +msgstr "Überprüfung" + +#: render.c:164 +msgid "wrong" +msgstr "falsch" + +#: render.c:167 +msgid "cleared" +msgstr "gelöscht" + +#: render.c:174 +msgid "Caps Lock" +msgstr "Feststelltaste" diff --git a/po/fr.po b/po/fr.po new file mode 100644 index 000000000..f86ea461d --- /dev/null +++ b/po/fr.po @@ -0,0 +1,34 @@ +# French translations for swaylock package. +# Copyright (C) 2020 THE swaylock'S COPYRIGHT HOLDER +# This file is distributed under the same license as the swaylock package. +# Automatically generated, 2020. +# +msgid "" +msgstr "" +"Project-Id-Version: swaylock 1.6\n" +"Report-Msgid-Bugs-To: https://github.com/swaywm/swaylock/issues\n" +"POT-Creation-Date: 2020-08-18 14:46+0200\n" +"PO-Revision-Date: 2020-08-18 14:50+0200\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: render.c:161 +msgid "verifying" +msgstr "vérification" + +#: render.c:164 +msgid "wrong" +msgstr "incorrect" + +#: render.c:167 +msgid "cleared" +msgstr "effacé" + +#: render.c:174 +msgid "Caps Lock" +msgstr "Verr Maj" diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 000000000..5f21ce18d --- /dev/null +++ b/po/meson.build @@ -0,0 +1,17 @@ +i18n = import('i18n') + +add_project_arguments( + [ + '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), + '-DLOCALEDIR="@0@"'.format(get_option('prefix') / get_option('localedir')) + ], + language:'c' +) +i18n.gettext(meson.project_name(), + args: [ + '--directory=' + meson.source_root(), + '--package-name=' + meson.project_name(), + '--package-version=' + meson.project_version(), + '--msgid-bugs-address=https://github.com/swaywm/swaylock/issues', + ] +) diff --git a/po/swaylock.pot b/po/swaylock.pot new file mode 100644 index 000000000..25a90add9 --- /dev/null +++ b/po/swaylock.pot @@ -0,0 +1,34 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the swaylock package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: swaylock 1.6\n" +"Report-Msgid-Bugs-To: https://github.com/swaywm/swaylock/issues\n" +"POT-Creation-Date: 2020-08-18 14:46+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: render.c:161 +msgid "verifying" +msgstr "" + +#: render.c:164 +msgid "wrong" +msgstr "" + +#: render.c:167 +msgid "cleared" +msgstr "" + +#: render.c:174 +msgid "Caps Lock" +msgstr "" diff --git a/render.c b/render.c index 65ef47c32..45a1e296e 100644 --- a/render.c +++ b/render.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "cairo.h" #include "background-image.h" #include "swaylock.h" @@ -157,20 +158,20 @@ void render_frame(struct swaylock_surface *surface) { } switch (state->auth_state) { case AUTH_STATE_VALIDATING: - text = "verifying"; + text = gettext("verifying"); break; case AUTH_STATE_INVALID: - text = "wrong"; + text = gettext("wrong"); break; case AUTH_STATE_CLEAR: - text = "cleared"; + text = gettext("cleared"); break; case AUTH_STATE_INPUT: case AUTH_STATE_INPUT_NOP: case AUTH_STATE_BACKSPACE: // Caps Lock has higher priority if (state->xkb.caps_lock && state->args.show_caps_lock_text) { - text = "Caps Lock"; + text = gettext("Caps Lock"); } else if (state->args.show_failed_attempts && state->failed_attempts > 0) { if (state->failed_attempts > 999) { @@ -193,7 +194,8 @@ void render_frame(struct swaylock_surface *surface) { ++curr_layout; } // will handle invalid index if none are active - layout_text = xkb_keymap_layout_get_name(state->xkb.keymap, curr_layout); + layout_text = dgettext("xkeyboard-config", + xkb_keymap_layout_get_name(state->xkb.keymap, curr_layout)); } break; default: