logo

badwolf

minimalist and privacy-oriented web browser based on WebKitGTK git clone https://hacktivis.me/git/badwolf.git
commit: 71f1d0b17e503c86aa9c03c7eca4374f46a67c35
parent d909a7cd27dc95451d184aa324505190f8c5d59b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 16 Jul 2023 04:19:06 +0200

userscripts: Improve error messages

Diffstat:

Mpo/fr.po22+++++++++++-----------
Mpo/messages.pot8++++----
Muserscripts.c11++++++++---
3 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/po/fr.po b/po/fr.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Badwolf 0.3.0+gd88f2e7\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2023-07-16 04:07+0200\n" +"POT-Creation-Date: 2023-07-16 04:25+0200\n" "PO-Revision-Date: 2021-04-10 18:43+0200\n" "Last-Translator: Haelwenn (lanodan) Monnier <contact@hacktivis.me>\n" "Language-Team: French\n" @@ -124,7 +124,7 @@ msgid "Open new tab" msgstr "Ouvrir un nouvel onglet" msgid "Out of Memory" -msgstr "Dépassement Mémoire" +msgstr "Manque de Mémoire" #, c-format msgid "Running Badwolf version: %s\n" @@ -158,31 +158,31 @@ msgstr "_JS" #, c-format msgid "badwolf: Checking for userscripts matching %s\n" -msgstr "" +msgstr "badwolf: Recherche de userscripts correspondant à %s\n" #, c-format -msgid "badwolf: Error getting userscript content: %s\n" -msgstr "" +msgid "badwolf: Error reading userscript: %s\n" +msgstr "badwolf: Erreur de lecture d'usercript: %s\n" #, c-format msgid "badwolf: Failed to list userscripts: Out of Memory\n" -msgstr "" +msgstr "badwolf: Échec de listage des userscripts : Manque de mémoire\n" #, c-format msgid "badwolf: Failed to list userscripts: Read Error\n" -msgstr "" +msgstr "badwolf: Échec de listage des userscripts : Erreur de lecture\n" #, c-format msgid "badwolf: Notice: Found %zd userscripts\n" -msgstr "" +msgstr "badwolf: Notice: %zd userscripts trouvés\n" #, c-format msgid "badwolf: Notice: No userscripts found\n" -msgstr "" +msgstr "badwolf: Notice: Aucun userscripts trouvés\n" #, c-format -msgid "badwolf: Notice: Userscripts loaded\n" -msgstr "" +msgid "badwolf: Notice: Userscript loading: %d loaded, %d failed to load\n" +msgstr "badwolf: Notice: Chargement des userscripts: %d chargés, %d en erreur\n" #, c-format msgid "badwolf: content-filter loaded, adding to content-manager…\n" diff --git a/po/messages.pot b/po/messages.pot @@ -4,9 +4,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Badwolf 1.2.0+geb77866.develop\n" +"Project-Id-Version: Badwolf 1.2.0+g5726ba86.userscripts\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2023-07-16 04:07+0200\n" +"POT-Creation-Date: 2023-07-16 04:25+0200\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" @@ -152,7 +152,7 @@ msgid "badwolf: Checking for userscripts matching %s\n" msgstr "" #, c-format -msgid "badwolf: Error getting userscript content: %s\n" +msgid "badwolf: Error reading userscript: %s\n" msgstr "" #, c-format @@ -172,7 +172,7 @@ msgid "badwolf: Notice: No userscripts found\n" msgstr "" #, c-format -msgid "badwolf: Notice: Userscripts loaded\n" +msgid "badwolf: Notice: Userscript loading: %d loaded, %d failed to load\n" msgstr "" #, c-format diff --git a/userscripts.c b/userscripts.c @@ -16,6 +16,7 @@ load_userscripts(WebKitUserContentManager *content_manager) { glob_t scripts_path_glob; gchar *scripts_path = g_build_filename(g_get_user_data_dir(), "badwolf", "scripts", "*.js", NULL); + unsigned int loaded = 0, failed = 0; fprintf(stderr, _("badwolf: Checking for userscripts matching %s\n"), scripts_path); @@ -40,9 +41,11 @@ load_userscripts(WebKitUserContentManager *content_manager) for(size_t i = 0; i < scripts_path_glob.gl_pathc; i++) { + char *filename = scripts_path_glob.gl_pathv[i]; gchar *contents; GError *err = NULL; - if(g_file_get_contents(scripts_path_glob.gl_pathv[i], &contents, NULL, &err) && err == NULL) + + if(g_file_get_contents(filename, &contents, NULL, &err) && err == NULL) { WebKitUserScript *userscript = @@ -52,15 +55,17 @@ load_userscripts(WebKitUserContentManager *content_manager) NULL, NULL); webkit_user_content_manager_add_script(content_manager, userscript); + loaded++; } else { - fprintf(stderr, _("badwolf: Error getting userscript content: %s\n"), err->message); + fprintf(stderr, _("badwolf: Error reading userscript: %s\n"), err->message); g_error_free(err); + failed++; } } - fprintf(stderr, _("badwolf: Notice: Userscripts loaded\n")); + fprintf(stderr, _("badwolf: Notice: Userscript loading: %d loaded, %d failed to load\n"), loaded, failed); clean: g_free(scripts_path);