logo

badwolf

minimalist and privacy-oriented web browser based on WebKitGTK git clone https://hacktivis.me/git/badwolf.git
commit: 5d8d10d0849e4d42d23bb92e5bc3c8ec194f4983
parent fef0bed45c212140f371e55839516458c7e2f5e0
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 11 Apr 2019 08:46:42 +0200

badwolf.c: Add gettext

Diffstat:

Mbadwolf.c31+++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)

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.\n"); - 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.\n"); - 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.\n"); - 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);