focus on your browsing
browser web-browser

add support for translations via gettext

add incomplete brazilian portuguese derrived from original codebase
implement settings support via gio settings
fix `content_sidebar_toggle` not being correct
add `<Alt>d` as an command palette shortcut

woof.monster f3451fb3 45a0cfb2

verified
+333 -29
+4
.zed/settings.json
··· 1 + { 2 + "tab_size": 4, 3 + "hard_tabs": true, 4 + }
+28 -12
Justfile
··· 1 1 set quiet 2 2 3 + PREFIX := "/usr" 3 4 ID := "site.srht.shrimple.OuchBrowser" 4 5 BLUEPRINT_FILES := "OuchBrowser/UI/Window.blp OuchBrowser/UI/Preferences.blp" 5 6 7 + run: build-blueprint compile-resources 8 + dotnet run --project OuchBrowser 9 + 10 + build: build-blueprint compile-resources 11 + dotnet build OuchBrowser 12 + 13 + publish: build-blueprint compile-resources 14 + dotnet publish OuchBrowser -c Release 15 + 16 + fmt: 17 + blueprint-compiler format -f -t -s 4 {{ BLUEPRINT_FILES }} 18 + dotnet format 19 + 20 + [group("build")] 6 21 build-blueprint: 7 22 blueprint-compiler batch-compile \ 8 23 OuchBrowser/UI \ 9 24 OuchBrowser/UI \ 10 25 {{ BLUEPRINT_FILES }} 11 26 27 + [group("build")] 12 28 compile-resources: 13 29 glib-compile-resources \ 14 30 --sourcedir OuchBrowser \ 15 31 --target=OuchBrowser/OuchBrowser.app.gresource \ 16 32 OuchBrowser/OuchBrowser.gresource.xml 17 33 18 - run: build-blueprint compile-resources 19 - dotnet run --project OuchBrowser 20 - 21 - build: build-blueprint compile-resources 22 - dotnet build OuchBrowser 23 - 34 + [group("build")] 24 35 build-flatpak: 25 36 @flatpak-builder \ 26 37 --force-clean \ ··· 33 44 {{ ID }}.flatpak \ 34 45 {{ ID }} \ 35 46 --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo 36 - 37 - publish: build-blueprint compile-resources 38 - dotnet publish OuchBrowser -c Release 39 47 40 - fmt: 41 - blueprint-compiler format -f -t -s 4 {{ BLUEPRINT_FILES }} 42 - dotnet format 48 + [group("build")] 49 + build-schemas: 50 + @sudo cp OuchBrowser/OuchBrowser.gschema.xml {{ PREFIX }}/share/glib-2.0/schemas 51 + @sudo glib-compile-schemas \ 52 + {{ PREFIX }}/share/glib-2.0/schemas \ 53 + >/dev/null 2>/dev/null 54 + 55 + [group("build")] 56 + build-translations: 57 + @mkdir -p {{ PREFIX }}/share/locale/pt_BR/LC_MESSAGES 58 + @msgfmt -o {{ PREFIX }}/share/locale/pt_BR/LC_MESSAGES/OuchBrowser.mo OuchBrowser/Gettext/pt_BR.po
+106
OuchBrowser/Gettext/Template.pot
··· 1 + msgid "" 2 + msgstr "" 3 + "Project-Id-Version: devel\n" 4 + "Report-Msgid-Bugs-To: https://tangled.org/shrimple.srht.site/OuchBrowser.NET" 5 + "/issues\n" 6 + "POT-Creation-Date: 2026-03-01 12:29:28-0400\n" 7 + "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 + "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 9 + "Language-Team: LANGUAGE <LL@li.org>\n" 10 + "Language: LL\n" 11 + "MIME-Version: 1.0\n" 12 + "Content-Type: text/plain; charset=UTF-8\n" 13 + "Content-Transfer-Encoding: 8bit\n" 14 + "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 15 + 16 + #: OuchBrowser/UI/Window.blp:16 17 + #: OuchBrowser/UI/Window.blp:287 18 + #: OuchBrowser/UI.cs:60 19 + msgid "Ouch Browser" 20 + msgstr "" 21 + 22 + #: OuchBrowser/UI/Window.blp:36 23 + msgid "Hide sidebar" 24 + msgstr "" 25 + 26 + #: OuchBrowser/UI/Window.blp:51 27 + msgid "Back" 28 + msgstr "" 29 + 30 + #: OuchBrowser/UI/Window.blp:61 31 + msgid "Forward" 32 + msgstr "" 33 + 34 + #: OuchBrowser/UI/Window.blp:71 35 + msgid "Refresh page" 36 + msgstr "" 37 + 38 + #: OuchBrowser/UI/Window.blp:111 39 + msgid "Reveal command palette" 40 + msgstr "" 41 + 42 + #: OuchBrowser/UI/Window.blp:180 43 + #: OuchBrowser/UI/Window.blp:498 44 + msgid "New tab" 45 + msgstr "" 46 + 47 + #: OuchBrowser/UI/Window.blp:248 48 + #: OuchBrowser/UI/Window.blp:467 49 + msgid "Archive" 50 + msgstr "" 51 + 52 + #: OuchBrowser/UI/Window.blp:271 53 + msgid "New..." 54 + msgstr "" 55 + 56 + #: OuchBrowser/UI/Window.blp:299 57 + msgid "Show sidebar" 58 + msgstr "" 59 + 60 + #: OuchBrowser/UI/Window.blp:374 61 + msgid "Search or enter URL..." 62 + msgstr "" 63 + 64 + #: OuchBrowser/UI/Window.blp:434 65 + msgid "Go" 66 + msgstr "" 67 + 68 + #: OuchBrowser/UI/Window.blp:448 69 + msgid "Close Palette" 70 + msgstr "" 71 + 72 + #: OuchBrowser/UI/Window.blp:468 73 + msgid "History" 74 + msgstr "" 75 + 76 + #: OuchBrowser/UI/Window.blp:469 77 + msgid "Downloads" 78 + msgstr "" 79 + 80 + #: OuchBrowser/UI/Window.blp:473 81 + msgid "Show all tabs" 82 + msgstr "" 83 + 84 + #: OuchBrowser/UI/Window.blp:478 85 + msgid "More" 86 + msgstr "" 87 + 88 + #: OuchBrowser/UI/Window.blp:479 89 + msgid "Preferences" 90 + msgstr "" 91 + 92 + #: OuchBrowser/UI/Window.blp:480 93 + msgid "Plugins manager" 94 + msgstr "" 95 + 96 + #: OuchBrowser/UI/Window.blp:484 97 + msgid "About Ouch Browser" 98 + msgstr "" 99 + 100 + #: OuchBrowser/UI/Window.blp:494 101 + msgid "New room" 102 + msgstr "" 103 + 104 + #: OuchBrowser/UI/Window.blp:495 105 + msgid "New folder" 106 + msgstr ""
+110
OuchBrowser/Gettext/pt_BR.po
··· 1 + # bee <micenest@pm.me>, 2024. 2 + # grayairr <grayair@proton.me>, 2024. 3 + msgid "" 4 + msgstr "" 5 + "Project-Id-Version: devel\n" 6 + "Report-Msgid-Bugs-To: https://tangled.org/shrimple.srht.site/OuchBrowser.NET" 7 + "/issues\n" 8 + "POT-Creation-Date: 2026-03-01 12:29:28-0400\n" 9 + "PO-Revision-Date: 2024-10-11 21:16+0000\n" 10 + "Last-Translator: grayairr <grayair@proton.me>\n" 11 + "Language-Team: Portuguese (Brazil) <https://hosted.weblate.org/projects/ouch/" 12 + "ouch/pt_BR/>\n" 13 + "Language: pt_BR\n" 14 + "MIME-Version: 1.0\n" 15 + "Content-Type: text/plain; charset=UTF-8\n" 16 + "Content-Transfer-Encoding: 8bit\n" 17 + "Plural-Forms: nplurals=2; plural=n > 1;\n" 18 + "X-Generator: Weblate 5.8-dev\n" 19 + 20 + #: OuchBrowser/UI/Window.blp:16 21 + #: OuchBrowser/UI/Window.blp:287 22 + #: OuchBrowser/UI.cs:60 23 + msgid "Ouch Browser" 24 + msgstr "Ouch Browser" 25 + 26 + #: OuchBrowser/UI/Window.blp:36 27 + msgid "Hide sidebar" 28 + msgstr "" 29 + 30 + #: OuchBrowser/UI/Window.blp:51 31 + msgid "Back" 32 + msgstr "Voltar" 33 + 34 + #: OuchBrowser/UI/Window.blp:61 35 + msgid "Forward" 36 + msgstr "Avançar" 37 + 38 + #: OuchBrowser/UI/Window.blp:71 39 + msgid "Refresh page" 40 + msgstr "" 41 + 42 + #: OuchBrowser/UI/Window.blp:111 43 + msgid "Reveal command palette" 44 + msgstr "" 45 + 46 + #: OuchBrowser/UI/Window.blp:180 47 + #: OuchBrowser/UI/Window.blp:498 48 + msgid "New tab" 49 + msgstr "Nova aba" 50 + 51 + #: OuchBrowser/UI/Window.blp:248 52 + #: OuchBrowser/UI/Window.blp:467 53 + msgid "Archive" 54 + msgstr "Arquivar" 55 + 56 + #: OuchBrowser/UI/Window.blp:271 57 + msgid "New..." 58 + msgstr "Novo…" 59 + 60 + #: OuchBrowser/UI/Window.blp:299 61 + msgid "Show sidebar" 62 + msgstr "" 63 + 64 + #: OuchBrowser/UI/Window.blp:374 65 + msgid "Search or enter URL..." 66 + msgstr "" 67 + 68 + #: OuchBrowser/UI/Window.blp:434 69 + msgid "Go" 70 + msgstr "" 71 + 72 + #: OuchBrowser/UI/Window.blp:448 73 + msgid "Close Palette" 74 + msgstr "" 75 + 76 + #: OuchBrowser/UI/Window.blp:468 77 + msgid "History" 78 + msgstr "" 79 + 80 + #: OuchBrowser/UI/Window.blp:469 81 + msgid "Downloads" 82 + msgstr "" 83 + 84 + #: OuchBrowser/UI/Window.blp:473 85 + msgid "Show all tabs" 86 + msgstr "" 87 + 88 + #: OuchBrowser/UI/Window.blp:478 89 + msgid "More" 90 + msgstr "" 91 + 92 + #: OuchBrowser/UI/Window.blp:479 93 + msgid "Preferences" 94 + msgstr "" 95 + 96 + #: OuchBrowser/UI/Window.blp:480 97 + msgid "Plugins manager" 98 + msgstr "" 99 + 100 + #: OuchBrowser/UI/Window.blp:484 101 + msgid "About Ouch Browser" 102 + msgstr "Sobre o Ouch Browser" 103 + 104 + #: OuchBrowser/UI/Window.blp:494 105 + msgid "New room" 106 + msgstr "" 107 + 108 + #: OuchBrowser/UI/Window.blp:495 109 + msgid "New folder" 110 + msgstr ""
+1
OuchBrowser/OuchBrowser.csproj
··· 14 14 </ItemGroup> 15 15 16 16 <ItemGroup> 17 + <PackageReference Include="GetText.NET" Version="10.0.1" /> 17 18 <PackageReference Include="GirCore.Adw-1" Version="0.7.0" /> 18 19 <PackageReference Include="GirCore.Gtk-4.0" Version="0.7.0" /> 19 20 <PackageReference Include="GirCore.WebKit-6.0" Version="0.7.0" />
+48
OuchBrowser/OuchBrowser.gschema.xml
··· 1 + <?xml version="1.0" encoding="UTF-8"?> 2 + <schemalist> 3 + <schema id="site.srht.shrimple.OuchBrowser" path="/site/srht/shrimple/OuchBrowser/" gettext-domain="OuchBrowser"> 4 + <key type="s" name="homepage"> 5 + <choices> 6 + <choice value="https://start.fedoraproject.org/"/> 7 + <choice value="https://start.ubuntu.com/"/> 8 + <choice value="https://search.vale.rocks/"/> 9 + </choices> 10 + <aliases> 11 + <alias value="FedoraStart" target="https://start.fedoraproject.org/"/> 12 + <alias value="UbuntuStartPage" target="https://start.ubuntu.com/"/> 13 + <alias value="SearchValeRocks" target="https://search.vale.rocks/"/> 14 + </aliases> 15 + 16 + <default>"https://start.ubuntu.com/"</default> 17 + <summary>Homepage</summary> 18 + <description> 19 + This value is the homepage that will be shown if the user hits 20 + the enter key when the command palette is shown and empty. 21 + </description> 22 + </key> 23 + 24 + <key type="s" name="search-engine"> 25 + <choices> 26 + <choice value="https://bing.com/search?q="/> 27 + <choice value="https://duckduckgo.com/?q="/> 28 + <choice value="https://ecosia.org/search?q="/> 29 + <choice value="https://google.com/search?q="/> 30 + <choice value="https://kagi.com/search?q="/> 31 + </choices> 32 + <aliases> 33 + <alias value="Bing" target="https://bing.com/search?q="/> 34 + <alias value="DuckDuckGo" target="https://duckduckgo.com/?q="/> 35 + <alias value="Ecosia" target="https://ecosia.org/search?q="/> 36 + <alias value="Google" target="https://google.com/search?q="/> 37 + <alias value="Kagi" target="https://kagi.com/search?q="/> 38 + </aliases> 39 + 40 + <default>"https://duckduckgo.com/?q="</default> 41 + <summary>Search engine</summary> 42 + <description> 43 + This value is the search engine that will be used when the user 44 + enters a search query into the command palette. 45 + </description> 46 + </key> 47 + </schema> 48 + </schemalist>
+8 -1
OuchBrowser/UI.cs
··· 1 1 using System.Reflection; 2 2 using Adw; 3 3 using Gtk; 4 + using GetText; 4 5 5 6 namespace OuchBrowser.UI; 6 7 7 8 public class Window : Adw.ApplicationWindow 8 9 { 10 + public Gio.Settings settings; 11 + public ICatalog gettext; 9 12 [Connect] public readonly Adw.HeaderBar? content_headerbar; 10 13 [Connect] public readonly ToolbarView? content_toolbar; 11 14 [Connect] public readonly Button? content_sidebar_toggle; ··· 27 30 28 31 public Window(Adw.Application app) : base() 29 32 { 33 + settings = Gio.Settings.New("site.srht.shrimple.OuchBrowser"); 34 + gettext = new Catalog("OuchBrowser", "/usr/share/locale"); 35 + 30 36 var assembly = Assembly.GetExecutingAssembly(); 31 37 using var stream = assembly.GetManifestResourceStream("UI/Window.ui"); 32 38 using var reader = new StreamReader(stream!); 33 39 string xml = reader.ReadToEnd(); 34 40 35 41 var builder = new Builder(); 42 + builder.SetTranslationDomain("OuchBrowser"); 36 43 builder.AddFromString(xml, -1); 37 44 builder.Connect(this); 38 45 ··· 51 58 DefaultHeight = 600; 52 59 WidthRequest = 350; 53 60 HeightRequest = 500; 54 - Title = "Ouch Browser"; 61 + Title = gettext.GetString("Ouch Browser"); 55 62 } 56 63 57 64 private void SetupHoverController(EventControllerMotion controller)
+10 -8
OuchBrowser/UI/Window.blp
··· 70 70 icon-name: "view-refresh-symbolic"; 71 71 tooltip-text: _("Refresh page"); 72 72 action-name: "win.refresh"; 73 - sensitive: false; 73 + sensitive: false; // this doesnt work for some reason now 74 74 75 75 styles [ 76 76 "flat", ··· 108 108 margin-start: 6; 109 109 margin-end: 6; 110 110 ellipsize: end; 111 - tooltip-text: _("Reveal Command Palette"); 111 + tooltip-text: _("Reveal command palette"); 112 112 113 113 styles [ 114 114 "font-medium", ··· 135 135 } 136 136 137 137 Label { 138 - label: _("Main"); 138 + label: "Main"; 139 139 halign: start; 140 140 margin-start: 14; 141 141 margin-end: 0; ··· 371 371 Entry url_entry { 372 372 input-purpose: url; 373 373 hexpand: true; 374 - placeholder-text: "Search or enter URL..."; 374 + placeholder-text: _("Search or enter URL..."); 375 375 receives-default: true; 376 376 width-request: 500; 377 377 ··· 431 431 } 432 432 433 433 Label { 434 - label: "Go"; 434 + label: _("Go"); 435 435 436 436 styles [ 437 437 "dimmed", ··· 445 445 visible: bind url_dialog.can-close; 446 446 447 447 Label { 448 - label: "Close Palette"; 448 + label: _("Close Palette"); 449 449 450 450 styles [ 451 451 "dimmed", ··· 491 491 492 492 menu new_menu { 493 493 section { 494 - label: _("New..."); 495 - item (_("New tab"), "win.palette-new") 496 494 item (_("New room")) 495 + item (_("New folder")) 496 + } 497 + section { 498 + item (_("New tab"), "win.palette-new") 497 499 } 498 500 }
+7 -8
OuchBrowser/Window.cs
··· 24 24 SetupActions(window, application, preferences); 25 25 26 26 // TODO: maybe make this a little bit less "hacky?" 27 - content_sidebar_toggle!.OnClicked += (_, _) => 27 + window.content_sidebar_toggle!.OnClicked += (_, _) => 28 28 { 29 - osv!.SetShowSidebar(true); 30 - sidebar_toggle!.SetActive(true); 29 + window.osv!.SetShowSidebar(true); 30 + window.sidebar_toggle!.SetActive(true); 31 31 }; 32 32 33 33 window.url_entry!.OnActivate += (entry, _) => ··· 56 56 } 57 57 else 58 58 { 59 - view.AddTab($"https://google.com/search?q={query}", false); 59 + view.AddTab($"{window.settings!.GetString("search-engine")}{query}", false); 60 60 } 61 61 } 62 62 else ··· 82 82 } 83 83 else 84 84 { 85 - webview.LoadUri($"https://google.com/search?q={query}"); 85 + webview.LoadUri($"{window.settings!.GetString("search-engine")}{query}"); 86 86 } 87 87 } 88 88 89 89 window.url_dialog!.ForceClose(); 90 90 window.url_dialog!.SetCanClose(true); 91 + window.overview!.SetOpen(false); 91 92 }; 92 93 93 94 window.overview!.OnCreateTab += (_, _) => ··· 115 116 palette_state = "new_tab"; 116 117 }); 117 118 118 - actions.AddAction("palette", ["<Ctrl>l"], (_, _) => 119 + actions.AddAction("palette", ["<Ctrl>l", "<Alt>d"], (_, _) => 119 120 { 120 121 if (window.view!.GetNPages() == 0) return; 121 - 122 - window.overview!.SetOpen(false); 123 122 124 123 TabPage page = window.view!.GetSelectedPage()!; 125 124 WebView webview = (WebView)page.Child!;
+7
flatpak-nuget-sources.json
··· 1 1 [ 2 2 { 3 3 "type": "file", 4 + "url": "https://api.nuget.org/v3-flatcontainer/gettext.net/10.0.1/gettext.net.10.0.1.nupkg", 5 + "sha512": "8bbc85bd485ae79286a9ff8cd0795157200d3b17c630420b8bdec424ae5b67481101defa8e63df7ab01c9d87634ebfd16a7e734b25ebf977001c05590e0df398", 6 + "dest": "nuget-sources", 7 + "dest-filename": "gettext.net.10.0.1.nupkg" 8 + }, 9 + { 10 + "type": "file", 4 11 "url": "https://api.nuget.org/v3-flatcontainer/gircore.adw-1/0.7.0/gircore.adw-1.0.7.0.nupkg", 5 12 "sha512": "1298f7513ed9fe550b3dae1f381a50c53d37cfb1fca0cb38ebcefeb5c08c8c86a3148259c84b86d8000e03898fe31521868bf413a2874033622279abf487cb30", 6 13 "dest": "nuget-sources",
+4
site.srht.shrimple.OuchBrowser.json
··· 88 88 "build-commands": [ 89 89 "just build-blueprint", 90 90 "just compile-resources", 91 + "just PREFIX=${FLATPAK_DEST} build-translations", 91 92 "dotnet publish -c Release -o /app/bin --source ./nuget-sources", 93 + 94 + "install -Dm644 OuchBrowser/OuchBrowser.gschema.xml --target-directory ${FLATPAK_DEST}/share/glib-2.0/schemas", 95 + "glib-compile-schemas ${FLATPAK_DEST}/share/glib-2.0/schemas", 92 96 93 97 "install -Dm644 OuchBrowser/Icons/Symbolic/${FLATPAK_ID}-symbolic.svg --target-directory ${FLATPAK_DEST}/share/icons/hicolor/symbolic/apps/", 94 98 "install -Dm644 OuchBrowser/Icons/Hicolor/${FLATPAK_ID}.svg --target-directory ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/",