Add c-based localization support

This commit is contained in:
Olli 2026-02-26 10:39:52 +01:00
commit d1bb505e0a
6 changed files with 428 additions and 60 deletions

38
internal/i18n/i18n.go Normal file
View file

@ -0,0 +1,38 @@
package i18n
/*
#include <locale.h>
#include <stdlib.h>
#include <libintl.h>
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))
}

Binary file not shown.

View file

@ -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 <olli@suruatoel.xyz>\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 "<i>none</i>"
msgstr "<i>nichts</i>"
#: 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)"

View file

@ -1,4 +1,9 @@
package main package main
import (
"suruatoel.xyz/mcg/internal/i18n"
)
func main() { func main() {
i18n.Init("mcg", "locale")
} }

View file

@ -1 +1 @@
en de de

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: mcg\n" "Project-Id-Version: mcg\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,19 +17,47 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: data/ui/connection-panel.ui:29 #: internal/common/album.go:93 internal/gui/coverpanel.go:290
msgid "No service found" #, go-format
msgid "%d:%d minutes"
msgstr "" 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" msgid "Host"
msgstr "" msgstr ""
#: data/ui/connection-panel.ui:56 #: data/ui/connection-panel.ui:38
msgid "Port" msgid "Port"
msgstr "" msgstr ""
#: data/ui/connection-panel.ui:76 #: data/ui/connection-panel.ui:57
msgid "Password" msgid "Password"
msgstr "" msgstr ""
@ -37,67 +65,67 @@ msgstr ""
msgid "Show the cover in fullscreen mode" msgid "Show the cover in fullscreen mode"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:34 #: data/ui/library-panel.ui:33
msgid "update library" msgid "update library"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:48 #: data/ui/library-panel.ui:46
msgid "Sort" msgid "Sort"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:53 #: data/ui/library-panel.ui:51
msgid "sort by artist" msgid "sort by artist"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:61 #: data/ui/library-panel.ui:58
msgid "sort by title" msgid "sort by title"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:69 #: data/ui/library-panel.ui:65
msgid "sort by year" msgid "sort by year"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:76 #: data/ui/library-panel.ui:71
msgid "sort by modification" msgid "sort by modification"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:84 #: data/ui/library-panel.ui:78
msgid "sort library descending" msgid "sort library descending"
msgstr "" 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" msgid "Search the library"
msgstr "" 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" msgid "Select multiple albums"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:135 #: data/ui/library-panel.ui:124
msgid "Settings and actions" msgid "Settings and actions"
msgstr "" msgstr ""
#: data/ui/library-panel.ui:160 #: data/ui/library-panel.ui:149
msgid "search library" msgid "search library"
msgstr "" 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" msgid "cancel"
msgstr "" 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" msgid "queue"
msgstr "" 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" msgid "play"
msgstr "" 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" msgid "Clear the playlist"
msgstr "" 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" msgid "remove"
msgstr "" msgstr ""
@ -198,7 +226,7 @@ msgstr ""
msgid "Connect or disconnect" msgid "Connect or disconnect"
msgstr "" 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" msgid "Switch between play and pause"
msgstr "" msgstr ""
@ -209,39 +237,3 @@ msgstr ""
#: data/ui/shortcuts-dialog.ui:95 #: data/ui/shortcuts-dialog.ui:95
msgid "Library Panel" msgid "Library Panel"
msgstr "" 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 ""