From d1bb505e0afb6e48d46783203ea8c5f1b69949e1 Mon Sep 17 00:00:00 2001 From: Olli Date: Thu, 26 Feb 2026 10:39:52 +0100 Subject: [PATCH] Add c-based localization support --- internal/i18n/i18n.go | 38 ++++ locale/de/LC_MESSAGES/mcg.mo | Bin 0 -> 3463 bytes locale/de/LC_MESSAGES/mcg.po | 333 +++++++++++++++++++++++++++++++++++ main.go | 5 + po/LINGUAS | 2 +- po/mcg.pot | 110 ++++++------ 6 files changed, 428 insertions(+), 60 deletions(-) create mode 100644 internal/i18n/i18n.go create mode 100644 locale/de/LC_MESSAGES/mcg.mo create mode 100644 locale/de/LC_MESSAGES/mcg.po diff --git a/internal/i18n/i18n.go b/internal/i18n/i18n.go new file mode 100644 index 0000000..40183e1 --- /dev/null +++ b/internal/i18n/i18n.go @@ -0,0 +1,38 @@ +package i18n + +/* +#include +#include +#include + +static void init_i18n(const char* domain, const char* localedir) { + setlocale(LC_ALL, ""); + bindtextdomain(domain, localedir); + bind_textdomain_codeset(domain, "UTF-8"); + textdomain(domain); +} +*/ +import "C" + +import ( + "log" + "unsafe" +) + +func Init(domain, localeDir string) { + cDomain := C.CString(domain) + defer C.free(unsafe.Pointer(cDomain)) + + cDir := C.CString(localeDir) + defer C.free(unsafe.Pointer(cDir)) + + log.Println("initialize localization for domain", domain, "with directory", localeDir) + C.init_i18n(cDomain, cDir) +} + +func T(msgid string) string { + c := C.CString(msgid) + defer C.free(unsafe.Pointer(c)) + + return C.GoString(C.gettext(c)) +} diff --git a/locale/de/LC_MESSAGES/mcg.mo b/locale/de/LC_MESSAGES/mcg.mo new file mode 100644 index 0000000000000000000000000000000000000000..79cb7795dd4fe89ae644322a346df451d0ad0046 GIT binary patch literal 3463 zcmca7#4?qEfq}uCfq_AWfq~%)BLjmc0|P@3Gf0$yVFL>T11|#u!$uYc25trhhW$|b zGz$X*8v_HwbruE&b_NE9dr)=HpyFRx7#KJh7#M!DFfa%)Ffg#NGBAiTFffR-GBB_* zFfiz{Ld-K}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amHUwO5x`L~SoSf3U^wd0s(!3M}$81pH335SVF(lI}WacV_<>%xi zW#**h=BJc`3fZdE%yf{N%v6Pt#Nv|FyzKnkq|7{UArFoKhyn$Tl+4s(P$dPfF*K11 z)y&kQQc$rDEn2fdZYoJEDJ^D*D$gtic~rqM3G6MX!va7>t3r8daz=4#P98&4X|4hy ztwAFNRT^C6KvNj13?gK)YD7dGIG*w#F^(`IF)67i734&QM3@s9QZw_4QZqsElbTnO zmRbZ#3kYjaA}}v8IYR-F+rZqzEqN*65GhVcEGf-p01Jj>mZauDm|lq)MIhTszyY74 a04k(2;h7G}qQvZy(!`uhQ2I{IV*mg+UUtF& literal 0 HcmV?d00001 diff --git a/locale/de/LC_MESSAGES/mcg.po b/locale/de/LC_MESSAGES/mcg.po new file mode 100644 index 0000000..8819521 --- /dev/null +++ b/locale/de/LC_MESSAGES/mcg.po @@ -0,0 +1,333 @@ +msgid "" +msgstr "" +"Project-Id-Version: CoverGrid (mcg)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-08-09 19:13+0200\n" +"PO-Revision-Date: 2026-08-14 09:34+0200\n" +"Last-Translator: coderkun \n" +"Language-Team: \n" +"Language: de_DE\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" +"X-Generator: Poedit 3.9\n" +"X-Poedit-Basepath: ../../..\n" +"X-Poedit-SourceCharset: UTF-8\n" + +#: internal/common/album.go:93 internal/gui/coverpanel.go:290 +#, go-format +msgid "%d:%d minutes" +msgstr "%d:%d Minuten" + +#: internal/gui/application.go:108 +msgid "" +"CoverGrid is a client for the Music Player Daemon, focusing on albums " +"instead of single tracks." +msgstr "" +"CoverGrid ist ein ein Client für den Music Player Daemon, der sich auf Alben " +"anstellen von einzelnen Songs fokussiert." + +#: internal/gui/coverpanel.go:277 +#, go-format +msgid "%s feat. %s" +msgstr "%s mit %s" + +#: internal/gui/window.go:117 +msgid "Server" +msgstr "Server" + +#: internal/gui/window.go:118 +msgid "Cover" +msgstr "Cover" + +#: internal/gui/window.go:119 +msgid "Playlist" +msgstr "Wiedergabeliste" + +#: internal/gui/window.go:120 +msgid "Library" +msgstr "Bibliothek" + +#: data/ui/connection-panel.ui:26 +msgid "Host" +msgstr "Host" + +#: data/ui/connection-panel.ui:38 +msgid "Port" +msgstr "Port" + +#: data/ui/connection-panel.ui:57 +msgid "Password" +msgstr "Passwort" + +#: data/ui/cover-panel.ui:12 data/ui/shortcuts-dialog.ui:88 +msgid "Show the cover in fullscreen mode" +msgstr "Das Cover im Vollbildmodus anzeigen" + +#: data/ui/library-panel.ui:33 +msgid "update library" +msgstr "Die Bibliothek aktualisieren" + +#: data/ui/library-panel.ui:46 +msgid "Sort" +msgstr "Sortierung" + +#: data/ui/library-panel.ui:51 +msgid "sort by artist" +msgstr "nach Künstler" + +#: data/ui/library-panel.ui:58 +msgid "sort by title" +msgstr "nach Titel" + +#: data/ui/library-panel.ui:65 +msgid "sort by year" +msgstr "nach Jahr" + +#: data/ui/library-panel.ui:71 +msgid "sort by modification" +msgstr "nach Änderungsdatum" + +#: data/ui/library-panel.ui:78 +msgid "sort library descending" +msgstr "absteigend sortieren" + +#: data/ui/library-panel.ui:98 data/ui/shortcuts-dialog.ui:99 +msgid "Search the library" +msgstr "Die Bibliothek durchsuchen" + +#: data/ui/library-panel.ui:111 data/ui/playlist-panel.ui:14 +msgid "Select multiple albums" +msgstr "Mehrere Alben auswählen" + +#: data/ui/library-panel.ui:124 +msgid "Settings and actions" +msgstr "Einstellungen und Aktionen" + +#: data/ui/library-panel.ui:149 +msgid "search library" +msgstr "Bibliothek durchsuchen" + +#: data/ui/library-panel.ui:216 data/ui/playlist-panel.ui:69 +msgid "cancel" +msgstr "abbrechen" + +#: data/ui/library-panel.ui:222 data/ui/library-panel.ui:277 +msgid "queue" +msgstr "einreihen" + +#: data/ui/library-panel.ui:271 data/ui/playlist-panel.ui:123 +msgid "play" +msgstr "abspielen" + +#: data/ui/playlist-panel.ui:27 data/ui/shortcuts-dialog.ui:77 +msgid "Clear the playlist" +msgstr "Die Wiedergabeliste leeren" + +#: data/ui/playlist-panel.ui:75 data/ui/playlist-panel.ui:129 +msgid "remove" +msgstr "entfernen" + +#: data/ui/server-panel.ui:35 +msgid "Status" +msgstr "Status" + +#: data/ui/server-panel.ui:49 +msgid "File:" +msgstr "Datei:" + +#: data/ui/server-panel.ui:60 +msgid "Audio:" +msgstr "Audio:" + +#: data/ui/server-panel.ui:71 +msgid "Bitrate:" +msgstr "Bitrate:" + +#: data/ui/server-panel.ui:82 +msgid "Error:" +msgstr "Fehler:" + +#: data/ui/server-panel.ui:92 data/ui/server-panel.ui:106 +#: data/ui/server-panel.ui:120 data/ui/server-panel.ui:134 +msgid "none" +msgstr "nichts" + +#: data/ui/server-panel.ui:154 +msgid "Statistics" +msgstr "Statistiken" + +#: data/ui/server-panel.ui:178 +msgid "Artists" +msgstr "Künstler" + +#: data/ui/server-panel.ui:198 +msgid "Albums" +msgstr "Alben" + +#: data/ui/server-panel.ui:218 +msgid "Songs" +msgstr "Songs" + +#: data/ui/server-panel.ui:238 +msgid "Seconds" +msgstr "Sekunden" + +#: data/ui/server-panel.ui:267 +msgid "Seconds played" +msgstr "Sekunden gespielt" + +#: data/ui/server-panel.ui:287 +msgid "Seconds running" +msgstr "Sekunden laufend" + +#: data/ui/server-panel.ui:303 +msgid "Audio Devices" +msgstr "Audiogeräte" + +#: data/ui/shortcuts-dialog.ui:14 +msgid "General" +msgstr "Allgemein" + +#: data/ui/shortcuts-dialog.ui:18 +msgid "Switch to the Connection panel" +msgstr "Zum Verbindungspaneel wechseln" + +#: data/ui/shortcuts-dialog.ui:24 +msgid "Switch to the Cover panel" +msgstr "Zum Cover-Paneel wechseln" + +#: data/ui/shortcuts-dialog.ui:30 +msgid "Switch to the Playlist panel" +msgstr "Zum Wiedergabelistenpaneel wechseln" + +#: data/ui/shortcuts-dialog.ui:36 +msgid "Switch to the Library panel" +msgstr "Zum Bibliothekspaneel wechseln" + +#: data/ui/shortcuts-dialog.ui:42 +msgid "Show the keyboard shortcuts" +msgstr "Die Tastenkombinationen anzeigen (dieser Dialog)" + +#: data/ui/shortcuts-dialog.ui:48 +msgid "Open the info dialog" +msgstr "Den Infodialog öffnen" + +#: data/ui/shortcuts-dialog.ui:54 +msgid "Quit the application" +msgstr "Die Anwendung beenden" + +#: data/ui/shortcuts-dialog.ui:61 +msgid "Player" +msgstr "Wiedergabeprogramm" + +#: data/ui/shortcuts-dialog.ui:65 +msgid "Connect or disconnect" +msgstr "Die Verbindung herstellen oder trennen" + +#: data/ui/shortcuts-dialog.ui:71 data/ui/window.ui:26 +msgid "Switch between play and pause" +msgstr "Zwischen Abspielen und Pause wechseln" + +#: data/ui/shortcuts-dialog.ui:84 +msgid "Cover Panel" +msgstr "Cover-Paneel" + +#: data/ui/shortcuts-dialog.ui:95 +msgid "Library Panel" +msgstr "Bibliothekspaneel" + +#~ msgid "No service found" +#~ msgstr "Keine Dienste gefunden" + +#~ msgid "use" +#~ msgstr "verwenden" + +#~ msgid "Loading albums" +#~ msgstr "Alben werden geladen" + +#~ msgid "Loading images" +#~ msgstr "Bilder werden geladen" + +#, fuzzy +#~ msgid "Connection state" +#~ msgstr "Verbindung" + +#~ msgid "Title" +#~ msgstr "Titel" + +#~ msgid "Artist" +#~ msgstr "Künstler" + +#~ msgid "Enter hostname or IP address" +#~ msgstr "Hostnamen oder IP-Adresse eingeben" + +#~ msgid "Enter password or leave blank" +#~ msgstr "Passwort eingeben oder leer lassen" + +#~ msgid "Connect" +#~ msgstr "Verbinden" + +#~ msgid "Play" +#~ msgstr "Abspielen" + +#~ msgid "Clear Playlist" +#~ msgstr "Playlist leeren" + +#~ msgid "Toggle Fullscreen" +#~ msgstr "Vollbild wechseln" + +#~ msgid "Search Library" +#~ msgstr "Bibliothek durchsuchen" + +#~ msgid "Connection" +#~ msgstr "Verbindung" + +#~ msgid "Keyboard Shortcuts" +#~ msgstr "Tastenkombinationen" + +#~ msgid "Info" +#~ msgstr "Info" + +#~ msgid "Quit" +#~ msgstr "Beenden" + +#~ msgid "Connect to MPD" +#~ msgstr "Zu MPD verbinden" + +#~ msgid "Adjust the volume" +#~ msgstr "Die Lautstärke anpassen" + +#~ msgid "Enter URL or local path" +#~ msgstr "URL oder lokalen Pfad eingeben" + +#~ msgid "Image Directory:" +#~ msgstr "Bildordner:" + +#~ msgid "{} of {} images loaded" +#~ msgstr "{} von {} Bildern geladen" + +#~ msgid "Tracklist" +#~ msgstr "Titelliste" + +#~ msgid "large tracklist" +#~ msgstr "große Titelliste" + +#~ msgid "small tracklist" +#~ msgstr "kleine Titelliste" + +#~ msgid "hide tracklist" +#~ msgstr "gar keine Titelliste" + +#~ msgid "_Play" +#~ msgstr "_Abspielen" + +#~ msgid "_Keyboard Shortcuts" +#~ msgstr "Tastenkombinationen" + +#~ msgid "_Quit" +#~ msgstr "_Beenden" + +#~ msgid "Show the keyboard shortcuts (this dialog)" +#~ msgstr "Die Tastenkombinationen anzeigen (dieser Dialog)" diff --git a/main.go b/main.go index da29a2c..b5aa37f 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,9 @@ package main +import ( + "suruatoel.xyz/mcg/internal/i18n" +) + func main() { + i18n.Init("mcg", "locale") } diff --git a/po/LINGUAS b/po/LINGUAS index 3ae2b72..7673daa 100644 --- a/po/LINGUAS +++ b/po/LINGUAS @@ -1 +1 @@ -en de +de diff --git a/po/mcg.pot b/po/mcg.pot index 451e0a8..f813837 100644 --- a/po/mcg.pot +++ b/po/mcg.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: mcg\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-22 14:39+0200\n" +"POT-Creation-Date: 2026-08-09 19:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,19 +17,47 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: data/ui/connection-panel.ui:29 -msgid "No service found" +#: internal/common/album.go:93 internal/gui/coverpanel.go:290 +#, go-format +msgid "%d:%d minutes" msgstr "" -#: data/ui/connection-panel.ui:43 +#: internal/gui/application.go:108 +msgid "" +"CoverGrid is a client for the Music Player Daemon, focusing on albums " +"instead of single tracks." +msgstr "" + +#: internal/gui/coverpanel.go:277 +#, go-format +msgid "%s feat. %s" +msgstr "" + +#: internal/gui/window.go:117 +msgid "Server" +msgstr "" + +#: internal/gui/window.go:118 +msgid "Cover" +msgstr "" + +#: internal/gui/window.go:119 +msgid "Playlist" +msgstr "" + +#: internal/gui/window.go:120 +msgid "Library" +msgstr "" + +#: data/ui/connection-panel.ui:26 msgid "Host" msgstr "" -#: data/ui/connection-panel.ui:56 +#: data/ui/connection-panel.ui:38 msgid "Port" msgstr "" -#: data/ui/connection-panel.ui:76 +#: data/ui/connection-panel.ui:57 msgid "Password" msgstr "" @@ -37,67 +65,67 @@ msgstr "" msgid "Show the cover in fullscreen mode" msgstr "" -#: data/ui/library-panel.ui:34 +#: data/ui/library-panel.ui:33 msgid "update library" msgstr "" -#: data/ui/library-panel.ui:48 +#: data/ui/library-panel.ui:46 msgid "Sort" msgstr "" -#: data/ui/library-panel.ui:53 +#: data/ui/library-panel.ui:51 msgid "sort by artist" msgstr "" -#: data/ui/library-panel.ui:61 +#: data/ui/library-panel.ui:58 msgid "sort by title" msgstr "" -#: data/ui/library-panel.ui:69 +#: data/ui/library-panel.ui:65 msgid "sort by year" msgstr "" -#: data/ui/library-panel.ui:76 +#: data/ui/library-panel.ui:71 msgid "sort by modification" msgstr "" -#: data/ui/library-panel.ui:84 +#: data/ui/library-panel.ui:78 msgid "sort library descending" msgstr "" -#: data/ui/library-panel.ui:105 data/ui/shortcuts-dialog.ui:99 +#: data/ui/library-panel.ui:98 data/ui/shortcuts-dialog.ui:99 msgid "Search the library" msgstr "" -#: data/ui/library-panel.ui:121 data/ui/playlist-panel.ui:14 +#: data/ui/library-panel.ui:111 data/ui/playlist-panel.ui:14 msgid "Select multiple albums" msgstr "" -#: data/ui/library-panel.ui:135 +#: data/ui/library-panel.ui:124 msgid "Settings and actions" msgstr "" -#: data/ui/library-panel.ui:160 +#: data/ui/library-panel.ui:149 msgid "search library" msgstr "" -#: data/ui/library-panel.ui:263 data/ui/playlist-panel.ui:107 +#: data/ui/library-panel.ui:216 data/ui/playlist-panel.ui:69 msgid "cancel" msgstr "" -#: data/ui/library-panel.ui:270 data/ui/library-panel.ui:327 +#: data/ui/library-panel.ui:222 data/ui/library-panel.ui:277 msgid "queue" msgstr "" -#: data/ui/library-panel.ui:320 data/ui/playlist-panel.ui:163 +#: data/ui/library-panel.ui:271 data/ui/playlist-panel.ui:123 msgid "play" msgstr "" -#: data/ui/playlist-panel.ui:28 data/ui/shortcuts-dialog.ui:77 +#: data/ui/playlist-panel.ui:27 data/ui/shortcuts-dialog.ui:77 msgid "Clear the playlist" msgstr "" -#: data/ui/playlist-panel.ui:114 data/ui/playlist-panel.ui:170 +#: data/ui/playlist-panel.ui:75 data/ui/playlist-panel.ui:129 msgid "remove" msgstr "" @@ -198,7 +226,7 @@ msgstr "" msgid "Connect or disconnect" msgstr "" -#: data/ui/shortcuts-dialog.ui:71 data/ui/window.ui:25 +#: data/ui/shortcuts-dialog.ui:71 data/ui/window.ui:26 msgid "Switch between play and pause" msgstr "" @@ -209,39 +237,3 @@ msgstr "" #: data/ui/shortcuts-dialog.ui:95 msgid "Library Panel" msgstr "" - -#: src/connectionpanel.py:51 -msgid "use" -msgstr "" - -#: src/librarypanel.py:291 -msgid "Loading albums" -msgstr "" - -#: src/librarypanel.py:379 -msgid "Loading images" -msgstr "" - -#: src/utils.py:50 src/utils.py:67 -msgid "{} feat. {}" -msgstr "" - -#: src/utils.py:61 -msgid "{}:{} minutes" -msgstr "" - -#: src/window.py:114 -msgid "Server" -msgstr "" - -#: src/window.py:115 -msgid "Cover" -msgstr "" - -#: src/window.py:116 -msgid "Playlist" -msgstr "" - -#: src/window.py:117 -msgid "Library" -msgstr ""