~kennylevinsen/gtkgreet

bf6c07be5019c83b274cefb94e3f7ad25944b29f — Savely Krasovsky 11 months ago 7d08f23
fix: get translations to work

Current state of project does not work with translations, AFAIK textdomain is necessary for app to read .mo files from localedir. I'm not very good with C and Meson, so it's based on GTK docs (https://docs.gtk.org/glib/i18n.html).

Signed-off-by: Savely Krasovsky <savely@krasovs.ky>
3 files changed, 12 insertions(+), 1 deletions(-)

M gtkgreet/main.c
M meson.build
M po/meson.build
M gtkgreet/main.c => gtkgreet/main.c +8 -0
@@ 6,6 6,9 @@
#include "window.h"
#include "gtkgreet.h"

#include <glib/gi18n.h>
#include <locale.h>

struct GtkGreet *gtkgreet = NULL;

static char* command = NULL;


@@ 119,6 122,11 @@ static void attach_custom_style(const char* path) {
}

int main (int argc, char **argv) {
    setlocale(LC_ALL, "");
    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain(GETTEXT_PACKAGE);

    GError *error = NULL;
    GOptionContext *option_context = g_option_context_new("- GTK-based greeter for greetd");
    g_option_context_add_main_entries(option_context, entries, NULL);

M meson.build => meson.build +3 -0
@@ 14,6 14,9 @@ project(
add_project_arguments('-Wno-unused-parameter', language: 'c')
add_project_arguments('-Wno-missing-braces', language: 'c')

prefix = get_option('prefix')
localedir = join_paths(prefix, get_option('localedir'))

subdir('po')
subdir('gtkgreet')


M po/meson.build => po/meson.build +1 -1
@@ 1,6 1,6 @@
i18n = import('i18n')
# define GETTEXT_PACKAGE
add_project_arguments('-DGETTEXT_PACKAGE="gtkgreet"', '-DLOCALEDIR="/usr/local/share/locale"', language:'c')
add_project_arguments('-DGETTEXT_PACKAGE="'+meson.project_name()+'"', '-DLOCALEDIR="'+localedir+'"', language:'c')
i18n.gettext(meson.project_name(),
    args: '--directory=' + meson.source_root(),
    preset: 'glib'