logo

badwolf

Minimalist and privacy-oriented WebKitGTK+ browser
commit: c11c1a8f35b0ee89df956029f2a77d55d5a28c42
parent: 8c0525b56e6ad402eeff18af58eb1ce4d9e8be47
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 26 Apr 2019 14:48:42 +0200

Merge branch 'features/localization' into develop

Diffstat:

MMakefile39+++++++++++++++++++++++++++------------
Mbadwolf.c31+++++++++++++++++++------------
Amo/.keep0
Apo/fr.po70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apo/messages.pot66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 182 insertions(+), 24 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,30 +1,45 @@ .POSIX: -PREFIX = /usr/local -BINDIR = $(PREFIX)/bin -MANDIR = $(PREFIX)/share/man +PREFIX = /usr/local +BINDIR = $(PREFIX)/bin +MANDIR = $(PREFIX)/share/man +DATADIR = $(PREFIX)/share/badwolf +PACKAGE = Badwolf -DEPS = gtk+-3.0 webkit2gtk-4.0 -OBJS = badwolf +DEPS = gtk+-3.0 webkit2gtk-4.0 +OBJS = badwolf +TRANS = fr.mo -CC = cc -CFLAGS = -g -Wall -Wextra -CDEPS = `pkg-config --cflags $(DEPS)` -LIBS = `pkg-config --libs $(DEPS)` +CC = cc +CFLAGS = -g -Wall -Wextra +CDEPS = `pkg-config --cflags $(DEPS)` -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" +LIBS = `pkg-config --libs $(DEPS)` -all: $(OBJS) +all: $(OBJS) $(TRANS) + +%.mo: + mkdir -p locale/$*/LC_MESSAGES + msgfmt -o locale/$*/LC_MESSAGES/$(PACKAGE).mo po/$*.po + +po/messages.pot: + xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j badwolf.c + +po/%.po: po/messages.pot + msgmerge --update $@ $< .c: $(CC) -std=c11 $(CFLAGS) $(CDEPS) -o $@ $< $(LDFLAGS) $(LIBS) -install: badwolf +install: all mkdir -p $(DESTDIR)$(BINDIR) cp -p badwolf $(DESTDIR)$(BINDIR)/badwolf mkdir -p $(DESTDIR)$(MANDIR)/man1 cp -p badwolf.1 $(DESTDIR)$(MANDIR)/man1 + mkdir -p $(DESTDIR)$(DATADIR)/locale + cp -r locale/ $(DESTDIR)$(DATADIR) clean: - rm $(OBJS) + rm -fr locale $(OBJS) format: *.c *.h clang-format -style=file -assume-filename=.clang-format -i *.c *.h diff --git a/badwolf.c b/badwolf.c @@ -4,8 +4,10 @@ #include "config.h" +#include <glib/gi18n.h> /* _() and other internationalization/localization helpers */ #include <glib/gprintf.h> /* g_fprintf() */ #include <gtk/gtk.h> +#include <locale.h> /* LC_* */ #include <webkit2/webkit2.h> struct Window @@ -95,16 +97,16 @@ WebViewCb_web_process_terminated(WebKitWebView *webView, switch(reason) { case WEBKIT_WEB_PROCESS_CRASHED: - g_fprintf(stderr, "the web process crashed."); - webView_tab_label_change(browser, "Crashed"); + g_fprintf(stderr, _("the web process crashed.\n")); + webView_tab_label_change(browser, _("title|Crashed")); break; case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT: - g_fprintf(stderr, "the web process exceeded the memory limit."); - webView_tab_label_change(browser, "Out of Memory"); + g_fprintf(stderr, _("the web process exceeded the memory limit.\n")); + webView_tab_label_change(browser, _("title|Out of Memory")); break; default: - g_fprintf(stderr, "the web process terminated for an unknown reason."); - webView_tab_label_change(browser, "Unknown Crash"); + g_fprintf(stderr, _("the web process terminated for an unknown reason.\n")); + webView_tab_label_change(browser, _("title|Unknown Crash")); } return FALSE; @@ -368,7 +370,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web settings, NULL)); - gtk_widget_set_tooltip_text(browser->javascript, "Toggle javascript"); + gtk_widget_set_tooltip_text(browser->javascript, _("Toggle javascript")); gtk_box_pack_start(GTK_BOX(browser->toolbar), GTK_WIDGET(browser->javascript), @@ -408,7 +410,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web gtk_entry_set_has_frame(GTK_ENTRY(browser->location), FALSE); gtk_entry_set_input_purpose(GTK_ENTRY(browser->location), GTK_INPUT_PURPOSE_URL); - gtk_entry_set_placeholder_text(GTK_ENTRY(browser->search), "search in current page"); + gtk_entry_set_placeholder_text(GTK_ENTRY(browser->search), _("search in current page")); gtk_entry_set_has_frame(GTK_ENTRY(browser->search), FALSE); g_signal_connect(browser->location, "activate", G_CALLBACK(locationCb_activate), browser); @@ -452,7 +454,7 @@ int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) { gint current_page = gtk_notebook_get_current_page(notebook); - gchar *title = "New tab"; + gchar *title = _("New tab"); gtk_widget_show_all(browser->box); @@ -516,13 +518,18 @@ main(int argc, char *argv[]) struct Window *window = g_malloc(sizeof(struct Client)); gchar *target_url = NULL; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, DATADIR "/locale"); + bind_textdomain_codeset(PACKAGE, "UTF-8"); + textdomain(PACKAGE); + g_fprintf(stderr, - "Buildtime WebKit version: %d.%d.%d\n", + _("Buildtime WebKit version: %d.%d.%d\n"), WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION); g_fprintf(stderr, - "Runtime WebKit version: %d.%d.%d\n", + _("Runtime WebKit version: %d.%d.%d\n"), webkit_get_major_version(), webkit_get_minor_version(), webkit_get_micro_version()); @@ -539,7 +546,7 @@ main(int argc, char *argv[]) GTK_WINDOW(window->main_window), BADWOLF_DEFAULT_WIDTH, BADWOLF_DEFAULT_HEIGHT); gtk_window_set_role(GTK_WINDOW(window->main_window), "browser"); - gtk_widget_set_tooltip_text(window->new_tab, "Open new tab"); + gtk_widget_set_tooltip_text(window->new_tab, _("Open new tab")); gtk_notebook_set_action_widget(GTK_NOTEBOOK(window->notebook), window->new_tab, GTK_PACK_END); gtk_notebook_set_scrollable(GTK_NOTEBOOK(window->notebook), TRUE); diff --git a/mo/.keep b/mo/.keep diff --git a/po/fr.po b/po/fr.po @@ -0,0 +1,70 @@ +# BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser +# Copyright (C) 2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# This file is distributed under the same license as the Badwolf package. +# Haelwenn (lanodan) Monnier <contact@hacktivis.me>, 2019 +# +msgid "" +msgstr "" +"Project-Id-Version: Badwolf 0.1.0\n" +"POT-Creation-Date: 2019-04-18 13:16+0200\n" +"PO-Revision-Date: 2019-04-11 09:28+0200\n" +"Last-Translator: <contact@hacktivis.me>\n" +"Language-Team: French\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" + +#: badwolf.c:527 +#, c-format +msgid "Buildtime WebKit version: %d.%d.%d\n" +msgstr "Version WebKit à la compilation: %d.%d.%d\n" + +#: badwolf.c:457 +msgid "New tab" +msgstr "Nouvel onglet" + +#: badwolf.c:549 +msgid "Open new tab" +msgstr "Ouvrir un nouvel onglet" + +#: badwolf.c:532 +#, c-format +msgid "Runtime WebKit version: %d.%d.%d\n" +msgstr "Version WebKit au lancement: %d.%d.%d\n" + +#: badwolf.c:373 +msgid "Toggle javascript" +msgstr "Activer/Désactiver javascript" + +#: badwolf.c:413 +msgid "search in current page" +msgstr "recherche dans la page courante" + +#: badwolf.c:100 +#, fuzzy +msgid "the web process crashed.\n" +msgstr "le processus web à cessé de fonctionner.\n" + +#: badwolf.c:104 +#, fuzzy +msgid "the web process exceeded the memory limit.\n" +msgstr "le processus web à dépassé la limitation de mémoire.\n" + +#: badwolf.c:108 +#, fuzzy +msgid "the web process terminated for an unknown reason.\n" +msgstr "le processus web s’est interrompu pour une raison inconnue.\n" + +#: badwolf.c:101 +msgid "title|Crashed" +msgstr "title|Crash" + +#: badwolf.c:105 +msgid "title|Out of Memory" +msgstr "title|Dépassement Mémoire" + +#: badwolf.c:109 +msgid "title|Unknown Crash" +msgstr "title|Crash inconnu" diff --git a/po/messages.pot b/po/messages.pot @@ -0,0 +1,66 @@ +# BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser +# Copyright (C) 2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# This file is distributed under the same license as the Badwolf package. +# Haelwenn (lanodan) Monnier <contact@hacktivis.me>, 2019 +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Badwolf 0.1.0\n" +"POT-Creation-Date: 2019-04-18 13:16+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: \"Haelwenn (lanodan) Monnier <contact@hacktivis.me>\"\n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: badwolf.c:527 +#, c-format +msgid "Buildtime WebKit version: %d.%d.%d\n" +msgstr "" + +#: badwolf.c:457 +msgid "New tab" +msgstr "" + +#: badwolf.c:549 +msgid "Open new tab" +msgstr "" + +#: badwolf.c:532 +#, c-format +msgid "Runtime WebKit version: %d.%d.%d\n" +msgstr "" + +#: badwolf.c:373 +msgid "Toggle javascript" +msgstr "" + +#: badwolf.c:413 +msgid "search in current page" +msgstr "" + +#: badwolf.c:100 +msgid "the web process crashed.\n" +msgstr "" + +#: badwolf.c:104 +msgid "the web process exceeded the memory limit.\n" +msgstr "" + +#: badwolf.c:108 +msgid "the web process terminated for an unknown reason.\n" +msgstr "" + +#: badwolf.c:101 +msgid "title|Crashed" +msgstr "" + +#: badwolf.c:105 +msgid "title|Out of Memory" +msgstr "" + +#: badwolf.c:109 +msgid "title|Unknown Crash" +msgstr ""