summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2018-06-28 21:35:23 +0200
committerSebastian Reichel <sre@ring0.de>2018-06-29 00:55:02 +0200
commit8e60fa48a8535da9eaa34ef35b5040c2eb68fc3b (patch)
treea19bdf74637b225eed75fdc084805c09df43c426
parentfb75ceb1c5a415cc6667043b1123e42586b1d9b1 (diff)
downloadserial-barcode-scanner-8e60fa48a8535da9eaa34ef35b5040c2eb68fc3b.tar.bz2
all: I18N support
This adds I18N support using standard gettext system together with an initial German translation. This can be used to search locales in some directory: Intl.bindtextdomain("shopsystem", "/home/sre/src/serial-barcode-scanner"); And this can be used to switch language at runtime: Intl.setlocale(LocaleCategory.ALL, "");
-rw-r--r--.gitignore2
-rw-r--r--Makefile14
-rw-r--r--locale/de.po481
-rw-r--r--src/audio/Makefile2
-rw-r--r--src/audio/audio.vala4
-rw-r--r--src/audio/main.vala17
-rw-r--r--src/backup/Makefile2
-rw-r--r--src/backup/main.vala5
-rw-r--r--src/cli/Makefile3
-rw-r--r--src/cli/cli.vala11
-rw-r--r--src/cli/main.vala26
-rw-r--r--src/config/Makefile2
-rw-r--r--src/config/config.vala2
-rw-r--r--src/config/main.vala11
-rw-r--r--src/curses-ui/Makefile2
-rw-r--r--src/curses-ui/dialog.vala6
-rw-r--r--src/curses-ui/logo.vala4
-rw-r--r--src/curses-ui/main.vala13
-rw-r--r--src/curses-ui/message_box.vala4
-rw-r--r--src/curses-ui/message_box_overlay.vala6
-rw-r--r--src/database/Makefile2
-rw-r--r--src/database/database.vala88
-rw-r--r--src/database/main.vala21
-rw-r--r--src/input-device/Makefile2
-rw-r--r--src/input-device/input-device.vala12
-rw-r--r--src/input-device/main.vala19
-rw-r--r--src/invoice/Makefile4
-rw-r--r--src/invoice/invoice.vala8
-rw-r--r--src/invoice/main.vala11
-rw-r--r--src/invoice/single.vala4
-rw-r--r--src/mail/Makefile2
-rw-r--r--src/mail/mailer.vala14
-rw-r--r--src/mail/main.vala13
-rw-r--r--src/pdf-invoice/Makefile4
-rw-r--r--src/pdf-invoice/main.vala17
-rw-r--r--src/pdf-invoice/pdf-invoice.vala20
-rw-r--r--src/pdf-stock/Makefile4
-rw-r--r--src/pdf-stock/main.vala11
-rw-r--r--src/pdf-stock/test.vala6
-rw-r--r--src/pgp/Makefile2
-rw-r--r--src/pgp/main.vala18
-rw-r--r--src/pgp/pgp.vala2
-rw-r--r--src/scanner-session/Makefile2
-rw-r--r--src/scanner-session/main.vala11
-rw-r--r--src/scanner-session/scannersession.vala46
-rw-r--r--src/serial-device/Makefile2
-rw-r--r--src/serial-device/main.vala17
-rw-r--r--src/serial-device/serial-device.vala20
-rw-r--r--src/web/Makefile2
-rw-r--r--src/web/main.vala21
-rw-r--r--src/web/template.vala24
-rw-r--r--src/web/web.vala4
-rw-r--r--src/web/websession.vala8
53 files changed, 795 insertions, 263 deletions
diff --git a/.gitignore b/.gitignore
index 359056d..026f4b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@ ktt-shopsystem.cfg
config.mk
config.h
.DS_Store
+locale/de.mo
+locale/messages.pot
diff --git a/Makefile b/Makefile
index d551b6b..ee08cef 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,18 @@
all:
@cd src && make --no-print-directory all
+gettext: locale/de/LC_MESSAGES/shopsystem.mo
+
+locale/de/LC_MESSAGES/shopsystem.mo: locale/de.po
+ install -d locale/de/LC_MESSAGES/
+ msgfmt -o $@ $<
+
+locale/%.po: locale/messages.pot
+ msgmerge -N --backup=off --update $@ $<
+
+locale/messages.pot: */*/*.vala
+ xgettext --language=vala --from-code=utf-8 --keyword=_ --escape --sort-output -o $@ */*/*.vala
+
clean:
@cd src && make --no-print-directory clean
@@ -14,4 +26,4 @@ shop.db: sql/tables.sql sql/views.sql sql/trigger.sql
sqlite3 shop.db < $$file; \
done
-.PHONY: all clean install
+.PHONY: all clean install gettext
diff --git a/locale/de.po b/locale/de.po
new file mode 100644
index 0000000..6aca21f
--- /dev/null
+++ b/locale/de.po
@@ -0,0 +1,481 @@
+# Copyright (C) 2018 Sebastian Reichel <sre@ring0.de>
+# This file is distributed under the same license as the main package.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: shopsystem 0.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2018-06-28 23:13+0200\n"
+"PO-Revision-Date: 2018-06-28 21:14+0200\n"
+"Last-Translator: Sebastian Reichel <sre@ring0.de>\n"
+"Language-Team: German\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/curses-ui/message_box.vala:52
+msgid ""
+"\n"
+"Date Changed: "
+msgstr ""
+"\n"
+"Datumswechsel: "
+
+#: src/scanner-session/scannersession.vala:289
+#, c-format
+msgid "%s bought %d items for %s €"
+msgstr "%s hat gerade %d Posten für %s € gekauft"
+
+#: src/web/template.vala:53 src/web/template.vala:55 src/web/template.vala:57
+#: src/web/template.vala:59 src/web/template.vala:82
+#, c-format
+msgid "%s could not be loaded!"
+msgstr "%s konnte nicht geladen werden!"
+
+#: src/web/template.vala:40 src/web/template.vala:43 src/web/template.vala:46
+#: src/web/template.vala:49 src/web/template.vala:78
+#, c-format
+msgid "%s not found!"
+msgstr "%s wurde nicht gefunden!"
+
+#: src/pdf-invoice/pdf-invoice.vala:591
+#, c-format
+msgid "Article name \"%s\" does not fit on a single page!"
+msgstr "Artikelname \"%s\" passt nicht auf eine Seite"
+
+#: src/serial-device/serial-device.vala:39
+msgid "Can't read lock file!\n"
+msgstr "Konnte Lock-Datei nicht lesen\n"
+
+#: src/audio/audio.vala:38
+msgid "Cannot find alsa GStreamer plugin"
+msgstr "GStreamer Plugin für ALSA konnte nicht gefunden werden"
+
+#: src/audio/audio.vala:42
+msgid "Cannot find playbin2 GStreamer plugin"
+msgstr "GStreamer Plugin playbin2 konnte nicht gefunden werden"
+
+#: src/audio/main.vala:39 src/database/main.vala:29
+#: src/input-device/main.vala:31 src/pdf-invoice/main.vala:30
+#: src/pgp/main.vala:35 src/serial-device/main.vala:29
+#, c-format
+msgid "Config Error: %s\n"
+msgstr "Konfigurationsfehler: %s\n"
+
+#: src/serial-device/serial-device.vala:211
+#, c-format
+msgid "Convert Error: %s"
+msgstr "Konvertierungsfehler"
+
+#: src/audio/main.vala:30 src/cli/main.vala:37 src/config/main.vala:32
+#: src/database/main.vala:40 src/input-device/main.vala:42
+#: src/pdf-invoice/main.vala:39 src/pdf-stock/main.vala:26 src/pgp/main.vala:44
+#: src/scanner-session/main.vala:28 src/serial-device/main.vala:40
+msgid "Could not acquire name\n"
+msgstr "Konnte DBus Namen nicht erlangen\n"
+
+#: src/input-device/input-device.vala:40
+#: src/serial-device/serial-device.vala:165
+msgid "Could not bind IOChannel"
+msgstr "IOChannel Verbindung konnte nicht hergestellt werden"
+
+#: src/serial-device/serial-device.vala:59
+#, c-format
+msgid "Could not create lock file: %s!\n"
+msgstr "Konnte Lock-Datei nicht erstellen: %s!\n"
+
+#: src/pdf-invoice/pdf-invoice.vala:81
+#, c-format
+msgid "Could not load SVG: %s\n"
+msgstr "Konnte SVG nicht laden: %s\n"
+
+#: src/config/config.vala:26
+#, c-format
+msgid "Could not load configuration file: %s"
+msgstr "Konnte Konfigurationsdatei nicht laden: %s"
+
+#: src/invoice/invoice.vala:338 src/pdf-invoice/pdf-invoice.vala:379
+#, c-format
+msgid "Could not open VAT template: %s"
+msgstr "Konnte VAT-Template nicht öffnen: %s"
+
+#: src/serial-device/serial-device.vala:55
+msgid "Could not open device!\n"
+msgstr "Konnte Gerätedatei nicht öffnen!\n"
+
+#: src/invoice/invoice.vala:252 src/invoice/invoice.vala:319
+#, c-format
+msgid "Could not open invoice template: %s"
+msgstr "Konnte Rechnungs-Template nicht öffnen: %s"
+
+#: src/audio/main.vala:53 src/cli/main.vala:68 src/config/main.vala:43
+#: src/database/main.vala:51 src/input-device/main.vala:53
+#: src/input-device/main.vala:58 src/pdf-stock/main.vala:37
+#: src/pgp/main.vala:55 src/scanner-session/main.vala:41
+#: src/serial-device/main.vala:51
+msgid "Could not register service\n"
+msgstr "Konnte DBus-Service nicht registrieren\n"
+
+#: src/pdf-invoice/main.vala:50
+#, c-format
+msgid "Could not register service: %s\n"
+msgstr "Konnte DBus-Servicenicht registieren: %s\n"
+
+#: src/web/web.vala:1482
+msgid "Could not setup webserver!"
+msgstr "Konnte Webserver nicht konfigurieren!"
+
+#: src/web/main.vala:64
+#, c-format
+msgid "Could not start Webserver: %s\n"
+msgstr "Konnte Webserver nicht starten: %s\n"
+
+#: src/scanner-session/scannersession.vala:300
+#, c-format
+msgid "DBus Error: %s"
+msgstr "DBus Fehler: %s"
+
+#: src/audio/main.vala:41 src/database/main.vala:31
+#: src/input-device/main.vala:33 src/pdf-invoice/main.vala:26
+#: src/pgp/main.vala:31 src/serial-device/main.vala:31 src/web/main.vala:51
+#, c-format
+msgid "DBus Error: %s\n"
+msgstr "DBus Fehler: %s\n"
+
+#: src/scanner-session/scannersession.vala:304
+#, c-format
+msgid "Database Error: %s"
+msgstr "Datenbank Fehler: %s"
+
+#: src/scanner-session/scannersession.vala:66
+#, c-format
+msgid "Error (user=%d): %s"
+msgstr "Fehler (Nutzer %d): %s"
+
+#: src/cli/main.vala:51
+#, c-format
+msgid "Error sending command: %s"
+msgstr "Fehler beim senden des Kommandos: %s"
+
+#: src/pgp/pgp.vala:123
+msgid "Error!\n"
+msgstr "Fehler!\n"
+
+#: src/curses-ui/logo.vala:44 src/scanner-session/scannersession.vala:178
+#: src/scanner-session/scannersession.vala:225
+#, c-format
+msgid "Error: %s"
+msgstr "Fehler: %s"
+
+#: src/backup/main.vala:41 src/invoice/main.vala:51 src/invoice/main.vala:58
+#: src/invoice/single.vala:51 src/invoice/single.vala:58 src/mail/main.vala:26
+#: src/web/web.vala:1143
+#, c-format
+msgid "Error: %s\n"
+msgstr "Fehler: %s\n"
+
+#: src/mail/main.vala:35
+msgid "Error: Could not acquire name\n"
+msgstr "Fehler: Konnte DBus-Namen nicht bekommen\n"
+
+#: src/mail/main.vala:47
+msgid "Error: Could not register service\n"
+msgstr "Fehler: Konnte DBus-Service nicht registrieren\n"
+
+#: src/database/database.vala:81
+msgid "Error: could not open database!"
+msgstr "Fehler: Konnte Datenbank nicht öffnen!"
+
+#: src/database/database.vala:28
+#, c-format
+msgid "Error: could not prepare statement: %s"
+msgstr "Fehler: Konnte SQL-Anweisung nicht erstellen: %s"
+
+#: src/scanner-session/scannersession.vala:174
+#: src/scanner-session/scannersession.vala:221
+#, c-format
+msgid "Error: unknown product: %llu"
+msgstr "Fehler: unbekanntes Produkt: %llu"
+
+#: src/serial-device/serial-device.vala:163
+msgid "Failed to set encoding"
+msgstr "Fehler beim setzten der Zeichenkodierung"
+
+#: src/curses-ui/logo.vala:31
+#, c-format
+msgid "File '%s' doesn't exist.\n"
+msgstr "Datei '%s' existiert nicht.\n"
+
+#: src/input-device/input-device.vala:43 src/pdf-stock/test.vala:24
+#, c-format
+msgid "File Error: %s"
+msgstr "Datei Fehler: %s"
+
+#: src/pdf-invoice/pdf-invoice.vala:387
+#, c-format
+msgid "File Error: %s\n"
+msgstr "Datei Fehler: %s\n"
+
+#: src/scanner-session/scannersession.vala:20
+msgid "Guest"
+msgstr "Gast"
+
+#: src/pdf-stock/test.vala:22 src/scanner-session/scannersession.vala:302
+#, c-format
+msgid "IO Error: %s"
+msgstr "EA Fehler: %s"
+
+#: src/audio/main.vala:37 src/curses-ui/main.vala:60 src/database/main.vala:27
+#: src/input-device/main.vala:29 src/pdf-invoice/main.vala:28
+#: src/pgp/main.vala:33 src/scanner-session/scannersession.vala:49
+#: src/serial-device/main.vala:27 src/web/main.vala:47
+#, c-format
+msgid "IO Error: %s\n"
+msgstr "EA Fehler: %s\n"
+
+#: src/serial-device/serial-device.vala:207
+#, c-format
+msgid "IOChannel Error: %s"
+msgstr "IOChannel Fehler: %s"
+
+#: src/serial-device/serial-device.vala:168
+#, c-format
+msgid "IOChannel: %s"
+msgstr "IOChannel: %s"
+
+#: src/input-device/input-device.vala:27
+msgid "Ignoring InputDevice!\n"
+msgstr "Eingabegerät wird ignoriert\n"
+
+#: src/scanner-session/scannersession.vala:168
+#: src/scanner-session/scannersession.vala:215
+msgid "Internal Error!"
+msgstr "Interner Fehler!"
+
+#: src/web/main.vala:44 src/web/main.vala:49
+#, c-format
+msgid "KeyFile Error: %s\n"
+msgstr "Schlüsseldatei Fehler: %s\n"
+
+#: src/scanner-session/scannersession.vala:149
+msgid "Login as GUEST"
+msgstr "Login als Gast"
+
+#: src/scanner-session/scannersession.vala:141
+#, c-format
+msgid "Login failed (User ID = %d)"
+msgstr "Login fehlgeschlagen (User ID = %d)"
+
+#: src/scanner-session/scannersession.vala:155
+msgid "Login failed as GUEST"
+msgstr "Gast-Login fehlgeschlagen"
+
+#: src/web/websession.vala:165
+#, c-format
+msgid "Login for user id %d failed\n"
+msgstr "Login für Benutzer %d fehlgeschlagen\n"
+
+#: src/scanner-session/scannersession.vala:135
+#, c-format
+msgid "Login: %s (%d)"
+msgstr "Login: %s (%d)"
+
+#: src/input-device/input-device.vala:215
+#: src/serial-device/serial-device.vala:189
+msgid "Lost device"
+msgstr "Gerät verloren"
+
+#: src/pdf-invoice/pdf-invoice.vala:628
+msgid "No invoice ID given!"
+msgstr "Keine Rechnungsnummer übergeben!"
+
+#: src/pdf-invoice/pdf-invoice.vala:631
+msgid "No invoice data given!"
+msgstr "Keine Rechnungsdaten übergeben!"
+
+#: src/pdf-invoice/pdf-invoice.vala:634
+msgid "No invoice date given!"
+msgstr "Kein Rechnungsdatum übergeben!"
+
+#: src/pdf-invoice/pdf-invoice.vala:637
+msgid "No invoice recipient given!"
+msgstr "Kein Rechnungsempfänger übergeben!"
+
+#: src/scanner-session/scannersession.vala:253
+msgid "No more Items on your Shopping Cart"
+msgstr "Keine weiteren Gegenstände im Einkaufswagen"
+
+#: src/mail/mailer.vala:141 src/mail/mailer.vala:149
+msgid "No such mail"
+msgstr "Mail wurde nicht gefunden"
+
+#: src/database/database.vala:611
+msgid "No such session available in database!"
+msgstr "Keine solche Session in der Datenbank verfügbar!"
+
+#: src/database/database.vala:710 src/database/database.vala:722
+msgid "No such user available in database!"
+msgstr "Kein solcher Nutzer in der Datenbank verfügbar!"
+
+#: src/cli/main.vala:25
+#, c-format
+msgid ""
+"Nothing to send.\n"
+"Usage: %s <commands to send...>\n"
+"Example: %s \"USER 1\" \"LOGOUT\"\n"
+msgstr ""
+"Nichts zu senden.\n"
+"Benutzung: %s <Kommandos zum senden...>\n"
+"Beispiel: %s \"USER 1\" \"LOGOUT\"\n"
+
+#: src/invoice/main.vala:20
+msgid "Possible values for <temporary>: temporary, final\n"
+msgstr "Mögliche Werte für <temporary>: temporary, final\n"
+
+#: src/pdf-invoice/pdf-invoice.vala:471
+msgid "Prices > 9999.99€ are not supported!"
+msgstr "Preise > 9999,99€ werden nicht unterstützt!"
+
+#: src/database/database.vala:487
+#, c-format
+msgid "Remove purchase of %s"
+msgstr "Einkaufsposten %s wurde entfernt"
+
+#: src/mail/mailer.vala:180
+#, c-format
+msgid "Reply from SMTP-Server: %s"
+msgstr "Antwort vom SMTP-Server: %s"
+
+#: src/cli/cli.vala:24
+#, c-format
+msgid "Sending: %s\n"
+msgstr "Sende: %s\n"
+
+#: src/curses-ui/main.vala:72
+msgid "Shop System has been started"
+msgstr "Shop System wurde gestartet"
+
+#: src/curses-ui/main.vala:78
+msgid "Stopping Shop System"
+msgstr "Shop System wird gestoppt"
+
+#: src/web/main.vala:55
+#, c-format
+msgid "TLS certificate: %s\n"
+msgstr "TLS Zertifikat: %s\n"
+
+#: src/web/main.vala:56
+#, c-format
+msgid "TLS private key: %s\n"
+msgstr "TLS Privater Schlüssel: %s\n"
+
+#: src/invoice/invoice.vala:314
+msgid "Unknown MessageType"
+msgstr "Unbekannter Nachrichten Typ"
+
+#: src/invoice/main.vala:19
+#, c-format
+msgid "Usage: %s <temporary> [timestamp]\n"
+msgstr "Benutzung: %s <temporary> [timestamp]\n"
+
+#: src/web/main.vala:54
+#, c-format
+msgid "Web Server Port: %u\n"
+msgstr "Webserver Port: %u\n"
+
+#: src/pdf-invoice/pdf-invoice.vala:475
+msgid "Years after 9999 are not supported!"
+msgstr "Jahre nach 9999 werden nicht unterstützt!"
+
+#: src/scanner-session/scannersession.vala:240
+#, c-format
+msgid "article added to shopping card: %s (%s €)"
+msgstr "Artikel %s (%s €) wurde zum Warenkorb hinzugefügt"
+
+#: src/scanner-session/scannersession.vala:189
+#, c-format
+msgid "article info: %s (Member: %s €, Guest: %s €"
+msgstr "Artikelinfo: %s (Mitglied: %s €, Gast: %s €"
+
+#: src/input-device/input-device.vala:249
+#, c-format
+msgid "barcode: %s\n"
+msgstr "Barcode: %s\n"
+
+#: src/mail/mailer.vala:107
+msgid "could not configure STARTTLS"
+msgstr "Konnte STARTTLS nicht konfigurieren"
+
+#: src/web/template.vala:61 src/web/template.vala:84
+msgid "could not load templates!"
+msgstr "Konnte Templates nicht laden!"
+
+#: src/curses-ui/main.vala:27 src/curses-ui/main.vala:29
+#, c-format
+msgid "could not play audio: %s"
+msgstr "Konnte Audio Datei nicht abspielen: %s"
+
+#: src/mail/mailer.vala:99
+msgid "could not setup server"
+msgstr "Konnte Server nicht konfigurieren"
+
+#: src/mail/mailer.vala:176
+msgid "eSMTP: Start Session failed!"
+msgstr "eSMTP: Session Start fehlgeschlagen!"
+
+#: src/database/database.vala:370 src/database/database.vala:387
+#: src/database/database.vala:403 src/database/database.vala:419
+#: src/database/database.vala:435 src/database/database.vala:448
+#: src/database/database.vala:470 src/database/database.vala:492
+#: src/database/database.vala:500 src/database/database.vala:527
+#: src/database/database.vala:541 src/database/database.vala:556
+#: src/database/database.vala:583 src/database/database.vala:591
+#: src/database/database.vala:601 src/database/database.vala:638
+#: src/database/database.vala:675 src/database/database.vala:689
+#: src/database/database.vala:700 src/database/database.vala:737
+#: src/database/database.vala:765 src/database/database.vala:884
+#: src/database/database.vala:892 src/database/database.vala:913
+#: src/database/database.vala:919 src/database/database.vala:927
+#: src/database/database.vala:1028 src/database/database.vala:1079
+#: src/database/database.vala:1129 src/database/database.vala:1212
+#, c-format
+msgid "internal error: %d"
+msgstr "Interner Fehler: %d"
+
+#: src/scanner-session/scannersession.vala:249
+#, c-format
+msgid "removed last Item from Shopping Cart: %s"
+msgstr "Letzter Posten wurde aus dem Warenkorb entfernt: %s"
+
+#: src/serial-device/serial-device.vala:43
+msgid "serial device is locked!\n"
+msgstr "Serielles Gerät ist blockiert!\n"
+
+#: src/mail/mailer.vala:79
+msgid "server or port configuration is missing"
+msgstr "Server oder Port Konfiguration fehlt"
+
+#: src/input-device/input-device.vala:224
+msgid "short read!\n"
+msgstr "Unvollständige Daten aus Gerätedatei gelesen\n"
+
+#: src/database/database.vala:490
+msgid "undo not possible without purchases"
+msgstr "Rückgängig nicht möglich ohne Einkäufe"
+
+#: src/database/database.vala:385 src/database/database.vala:401
+#: src/database/database.vala:417 src/database/database.vala:433
+#: src/database/database.vala:468
+#, c-format
+msgid "unknown product: %llu"
+msgstr "Unbekanntes Produkt: %llu"
+
+#: src/database/database.vala:1210
+#, c-format
+msgid "unknown rfid: %s"
+msgstr "Unbekannter RFID: %s"
+
+#: src/database/database.vala:636
+msgid "user not found"
+msgstr "User nicht gefunden"
diff --git a/src/audio/Makefile b/src/audio/Makefile
index 950287a..31d373d 100644
--- a/src/audio/Makefile
+++ b/src/audio/Makefile
@@ -2,7 +2,7 @@ all: audio
@echo > /dev/null
audio: main.vala audio.vala audio-interface.vala ../config/config-interface.vala
- valac -X -w -o $@ --pkg gstreamer-1.0 --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg gstreamer-1.0 --pkg gio-2.0 $^
clean:
rm -rf audio
diff --git a/src/audio/audio.vala b/src/audio/audio.vala
index ccced20..679e5c7 100644
--- a/src/audio/audio.vala
+++ b/src/audio/audio.vala
@@ -35,11 +35,11 @@ public class AudioPlayerImplementation {
var alsa = Gst.ElementFactory.make("alsasink", "alsa");
if (alsa == null)
- throw new GLib.IOError.FAILED("Cannot find alsa GStreamer plugin");
+ throw new GLib.IOError.FAILED(_("Cannot find alsa GStreamer plugin"));
p = Gst.ElementFactory.make("playbin", "player");
if (p == null)
- throw new GLib.IOError.FAILED("Cannot find playbin2 GStreamer plugin");
+ throw new GLib.IOError.FAILED(_("Cannot find playbin2 GStreamer plugin"));
p.set("audio-sink", alsa);
p.get_bus().add_watch(Priority.DEFAULT, bus_callback);
diff --git a/src/audio/main.vala b/src/audio/main.vala
index 2a7d918..4a1da2f 100644
--- a/src/audio/main.vala
+++ b/src/audio/main.vala
@@ -18,24 +18,27 @@ AudioPlayerImplementation player;
public static int main(string[] args) {
Gst.init(ref args);
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.AudioPlayer",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
try {
Config cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
var path = cfg.get_string("AUDIO", "path");
player = new AudioPlayerImplementation(path);
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
} catch(KeyFileError e) {
- error("Config Error: %s\n", e.message);
+ error(_("Config Error: %s\n"), e.message);
} catch(DBusError e) {
- error("DBus Error: %s\n", e.message);
+ error(_("DBus Error: %s\n"), e.message);
}
new MainLoop().run();
@@ -43,10 +46,10 @@ public static int main(string[] args) {
return 0;
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
con.register_object("/io/mainframe/shopsystem/audio", player);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/backup/Makefile b/src/backup/Makefile
index de8eee3..f2594c2 100644
--- a/src/backup/Makefile
+++ b/src/backup/Makefile
@@ -2,7 +2,7 @@ all: backup
@echo > /dev/null
backup: main.vala ../mail/mailer-interface.vala ../config/config-interface.vala
- valac -X -w -o $@ --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg gio-2.0 $^
clean:
rm -f backup
diff --git a/src/backup/main.vala b/src/backup/main.vala
index 4aed71f..670e56a 100644
--- a/src/backup/main.vala
+++ b/src/backup/main.vala
@@ -14,6 +14,9 @@
*/
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
try {
Mailer mailer = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Mail", "/io/mainframe/shopsystem/mailer");
Config cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
@@ -35,7 +38,7 @@ public static int main(string[] args) {
mailer.send_mail(mailpath);
} catch(Error e) {
- stderr.printf("Error: %s\n", e.message);
+ stderr.printf(_("Error: %s\n"), e.message);
}
return 0;
diff --git a/src/cli/Makefile b/src/cli/Makefile
index f042ca8..a66ce8f 100644
--- a/src/cli/Makefile
+++ b/src/cli/Makefile
@@ -2,8 +2,7 @@ all: cli
@echo > /dev/null
cli: main.vala cli.vala cli-interface.vala ../config/config-interface.vala
- valac -X -w -o $@ --pkg linux --pkg posix --pkg gio-2.0 $^
-
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg linux --pkg posix --pkg gio-2.0 $^
clean:
rm -rf cli
diff --git a/src/cli/cli.vala b/src/cli/cli.vala
index c0ba61e..0d0e9d4 100644
--- a/src/cli/cli.vala
+++ b/src/cli/cli.vala
@@ -15,14 +15,13 @@
[DBus (name = "io.mainframe.shopsystem.Cli")]
public class CliImpl {
-
public signal void received_barcode(string barcode);
public CliImpl() {
- }
+ }
- public void send(string msg) throws IOError, DBusError {
- stdout.printf("Sending: %s\n", msg);
- received_barcode(msg);
- }
+ public void send(string msg) throws IOError, DBusError {
+ stdout.printf(_("Sending: %s\n"), msg);
+ received_barcode(msg);
+ }
}
diff --git a/src/cli/main.vala b/src/cli/main.vala
index 377efa1..aacb3ba 100644
--- a/src/cli/main.vala
+++ b/src/cli/main.vala
@@ -18,20 +18,23 @@ MainLoop ml;
string[] commands;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
if (args.length == 1) {
- stdout.printf("Nothing to send.\nUsage: %s <commnds to send...>\nExample: %s \"USER 1\" \"LOGOUT\"\n", args[0], args[0]);
+ stdout.printf(_("Nothing to send.\nUsage: %s <commands to send...>\nExample: %s \"USER 1\" \"LOGOUT\"\n"), args[0], args[0]);
return 0;
}
commands = args[1:args.length];
-
+
cli = new CliImpl();
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.Cli",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
- on_name_aquired,
- () => stderr.printf("Could not aquire name\n"));
+ on_bus_acquired,
+ on_name_acquired,
+ () => stderr.printf(_("Could not acquire name\n")));
ml = new MainLoop();
@@ -40,12 +43,12 @@ public static int main(string[] args) {
return 0;
}
-void on_name_aquired() {
+void on_name_acquired() {
foreach (string cmd in commands) {
try {
cli.send(cmd);
} catch (Error e) {
- stderr.printf("Error sending command: %s", e.message);
+ stderr.printf(_("Error sending command: %s"), e.message);
}
}
@@ -55,15 +58,14 @@ void on_name_aquired() {
ml.quit ();
return false;
});
- time.attach (ml.get_context ());
-
+ time.attach (ml.get_context ());
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
- con.register_object("/io/mainframe/shopsystem/cli", cli);
+ con.register_object("/io/mainframe/shopsystem/cli", cli);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/config/Makefile b/src/config/Makefile
index d93d5df..bda0cbb 100644
--- a/src/config/Makefile
+++ b/src/config/Makefile
@@ -2,7 +2,7 @@ all: config
@echo > /dev/null
config: main.vala config.vala config-interface.vala
- valac -X -w -o $@ --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg gio-2.0 $^
clean:
rm -rf config
diff --git a/src/config/config.vala b/src/config/config.vala
index b25b667..bc476f4 100644
--- a/src/config/config.vala
+++ b/src/config/config.vala
@@ -23,7 +23,7 @@ public class Cfg {
this.file = new KeyFile();
this.file.load_from_file(file, KeyFileFlags.NONE);
} catch(Error e) {
- error("Could not load configuration file: %s", e.message);
+ error(_("Could not load configuration file: %s"), e.message);
}
}
diff --git a/src/config/main.vala b/src/config/main.vala
index 5ae15be..c24b572 100644
--- a/src/config/main.vala
+++ b/src/config/main.vala
@@ -16,6 +16,9 @@
Cfg cfg;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
string binarylocation = File.new_for_path(args[0]).get_parent().get_path();
cfg = new Cfg(binarylocation + "/../../ktt-shopsystem.cfg");
@@ -24,19 +27,19 @@ public static int main(string[] args) {
BusType.SYSTEM,
"io.mainframe.shopsystem.Config",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
con.register_object("/io/mainframe/shopsystem/config", cfg);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/curses-ui/Makefile b/src/curses-ui/Makefile
index bfdea51..2fa44b3 100644
--- a/src/curses-ui/Makefile
+++ b/src/curses-ui/Makefile
@@ -2,7 +2,7 @@ all: curses-ui
@echo > /dev/null
curses-ui: *.vala ../audio/audio-interface.vala ../scanner-session/scannersession-interface.vala ../config/config-interface.vala
- valac -X -w -o $@ --pkg curses -X -lncursesw --pkg posix --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg curses -X -lncursesw --pkg posix --pkg gio-2.0 $^
clean:
rm -rf curses-ui
diff --git a/src/curses-ui/dialog.vala b/src/curses-ui/dialog.vala
index 7d2902b..e7ae0b8 100644
--- a/src/curses-ui/dialog.vala
+++ b/src/curses-ui/dialog.vala
@@ -51,7 +51,7 @@ public class Dialog {
if (countdownValue > 0) {
Timeout.add_seconds(1, decrementTitleCountdown);
- }
+ }
}
private void setTitle() {
@@ -61,7 +61,7 @@ public class Dialog {
}
int title_x = (dialogWidth-title.length)/2;
win.mvaddstr(0, title_x, title);
- win.mvaddch(0, title_x-2, Acs.RTEE);
+ win.mvaddch(0, title_x-2, Acs.RTEE);
win.mvaddch(0, title_x-1, ' ');
win.mvaddch(0, title_x+title.length, ' ');
win.mvaddch(0, title_x+title.length+1, Acs.LTEE);
@@ -70,7 +70,7 @@ public class Dialog {
win.mvaddch(0, title_x+title.length+3, Acs.HLINE);
}
- private bool decrementTitleCountdown() {
+ private bool decrementTitleCountdown() {
countdownValue--;
setTitle();
win.refresh();
diff --git a/src/curses-ui/logo.vala b/src/curses-ui/logo.vala
index 6a75ba1..e7f6fb8 100644
--- a/src/curses-ui/logo.vala
+++ b/src/curses-ui/logo.vala
@@ -28,7 +28,7 @@ public class Logo {
var file = File.new_for_path (binarylocation + "/../../logo.txt");
if (!file.query_exists ()) {
- stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
+ stderr.printf (_("File '%s' doesn't exist.\n"), file.get_path ());
}
try {
@@ -41,7 +41,7 @@ public class Logo {
win.addstr(line+"\n");
}
} catch (Error e) {
- error ("%s", e.message);
+ error (_("Error: %s"), e.message);
}
win.clrtobot();
diff --git a/src/curses-ui/main.vala b/src/curses-ui/main.vala
index 8a46db8..e5ad4c8 100644
--- a/src/curses-ui/main.vala
+++ b/src/curses-ui/main.vala
@@ -24,9 +24,9 @@ private static void play(string file) {
try {
audio.play_system(file);
} catch(IOError e) {
- ui.log(MessageType.WARNING, "could not play audio: %s".printf(e.message));
+ ui.log(MessageType.WARNING, _("could not play audio: %s").printf(e.message));
} catch(DBusError e) {
- ui.log(MessageType.WARNING, "could not play audio: %s".printf(e.message));
+ ui.log(MessageType.WARNING, _("could not play audio: %s").printf(e.message));
}
}
@@ -46,6 +46,9 @@ public void log_handler(string? log_domain, LogLevelFlags flags, string message)
public static int main(string[] args) {
loop = new MainLoop();
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
/* handle unix signals */
Unix.signal_add(Posix.Signal.TERM, handle_signals);
Unix.signal_add(Posix.Signal.INT, handle_signals);
@@ -54,7 +57,7 @@ public static int main(string[] args) {
audio = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.AudioPlayer", "/io/mainframe/shopsystem/audio");
scanner = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.ScannerSession", "/io/mainframe/shopsystem/scanner_session");
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
}
string binarylocation = File.new_for_path(args[0]).get_parent().get_path();
@@ -66,13 +69,13 @@ public static int main(string[] args) {
scanner.msg.connect(msg_handler);
scanner.msg_overlay.connect(msg_overlay_handler);
- ui.log(MessageType.INFO, "Shop System has been started");
+ ui.log(MessageType.INFO, _("Shop System has been started"));
play("startup.ogg");
/* run mainloop */
loop.run();
- ui.log(MessageType.INFO, "Stopping Shop System");
+ ui.log(MessageType.INFO, _("Stopping Shop System"));
play("shutdown.ogg");
/* leave curses mode */
diff --git a/src/curses-ui/message_box.vala b/src/curses-ui/message_box.vala
index d6823fe..70c4d10 100644
--- a/src/curses-ui/message_box.vala
+++ b/src/curses-ui/message_box.vala
@@ -41,7 +41,7 @@ public class MessageBox {
init_pair (INFO_COLOR, Color.WHITE, Color.BLACK);
init_pair (WARN_COLOR, Color.YELLOW, Color.BLACK);
- init_pair (ERROR_COLOR, Color.RED, Color.BLACK);
+ init_pair (ERROR_COLOR, Color.RED, Color.BLACK);
}
public void add(string msg, short color_pair = MessageBox.INFO_COLOR) {
@@ -49,7 +49,7 @@ public class MessageBox {
if(now.get_day_of_year() != last.get_day_of_year() || now.get_year() != last.get_year()) {
string curtime = now.format("%Y-%m-%d");
- subwin.addstr("\nDate Changed: " + curtime);
+ subwin.addstr(_("\nDate Changed: ") + curtime);
}
last = now;
diff --git a/src/curses-ui/message_box_overlay.vala b/src/curses-ui/message_box_overlay.vala
index 721ab06..7b5a09b 100644
--- a/src/curses-ui/message_box_overlay.vala
+++ b/src/curses-ui/message_box_overlay.vala
@@ -37,13 +37,13 @@ public class MessageBoxOverlay {
Timeout.add_seconds(1, decrementTitleCountdown);
}
- private void setTitle() {
+ private void setTitle() {
var title = " === %s (%d) === ".printf(dialogTitle, countdownValue);
int title_x = (COLS - title.length)/2;
- win.mvaddstr(0, title_x, title);
+ win.mvaddstr(0, title_x, title);
}
- private bool decrementTitleCountdown() {
+ private bool decrementTitleCountdown() {
countdownValue--;
setTitle();
win.refresh();
diff --git a/src/database/Makefile b/src/database/Makefile
index 986f1f6..9e2956e 100644
--- a/src/database/Makefile
+++ b/src/database/Makefile
@@ -2,7 +2,7 @@ all: database
@echo > /dev/null
database: main.vala database.vala db-interface.vala ../config/config-interface.vala ../price.vapi
- valac -X -w -o $@ --pkg sqlite3 --pkg gee-0.8 --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg sqlite3 --pkg gee-0.8 --pkg gio-2.0 $^
clean:
rm -rf database
diff --git a/src/database/database.vala b/src/database/database.vala
index 121c793..cd2b947 100644
--- a/src/database/database.vala
+++ b/src/database/database.vala
@@ -25,7 +25,7 @@ public class DataBase : Object {
int rc = db.prepare_v2(query, -1, out stmt);
if(rc != Sqlite.OK) {
- error("could not prepare statement: %s", query);
+ error(_("Error: could not prepare statement: %s"), query);
}
}
@@ -78,7 +78,7 @@ public class DataBase : Object {
rc = Sqlite.Database.open(file, out db);
if(rc != Sqlite.OK) {
- error("could not open database!");
+ error(_("Error: could not open database!"));
}
/* setup queries */
@@ -367,7 +367,7 @@ public class DataBase : Object {
rc = statements["purchase"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
return true;
}
@@ -382,9 +382,9 @@ public class DataBase : Object {
case Sqlite.ROW:
return statements["product_name"].column_text(0);
case Sqlite.DONE:
- throw new DatabaseError.PRODUCT_NOT_FOUND("unknown product: %llu", article);
+ throw new DatabaseError.PRODUCT_NOT_FOUND(_("unknown product: %llu"), article);
default:
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -398,9 +398,9 @@ public class DataBase : Object {
case Sqlite.ROW:
return statements["product_category"].column_text(0);
case Sqlite.DONE:
- throw new DatabaseError.PRODUCT_NOT_FOUND("unknown product: %llu", article);
+ throw new DatabaseError.PRODUCT_NOT_FOUND(_("unknown product: %llu"), article);
default:
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -414,9 +414,9 @@ public class DataBase : Object {
case Sqlite.ROW:
return statements["product_amount"].column_int(0);
case Sqlite.DONE:
- throw new DatabaseError.PRODUCT_NOT_FOUND("unknown product: %llu", article);
+ throw new DatabaseError.PRODUCT_NOT_FOUND(_("unknown product: %llu"), article);
default:
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -430,9 +430,9 @@ public class DataBase : Object {
case Sqlite.ROW:
return statements["product_deprecated"].column_int(0) == 1;
case Sqlite.DONE:
- throw new DatabaseError.PRODUCT_NOT_FOUND("unknown product: %llu", article);
+ throw new DatabaseError.PRODUCT_NOT_FOUND(_("unknown product: %llu"), article);
default:
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -445,7 +445,7 @@ public class DataBase : Object {
rc = statements["product_set_deprecated"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
public Price get_product_price(int user, uint64 article) throws DBusError, IOError, DatabaseError {
@@ -465,9 +465,9 @@ public class DataBase : Object {
else
return statements["price"].column_int(1);
case Sqlite.DONE:
- throw new DatabaseError.PRODUCT_NOT_FOUND("unknown product: %llu", article);
+ throw new DatabaseError.PRODUCT_NOT_FOUND(_("unknown product: %llu"), article);
default:
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -484,12 +484,12 @@ public class DataBase : Object {
case Sqlite.ROW:
pid = uint64.parse(statements["last_purchase"].column_text(0));
pname = get_product_name(pid);
- write_to_log("Remove purchase of %s", pname);
+ stderr.printf(_("Remove purchase of %s"), pname);
break;
case Sqlite.DONE:
- throw new DatabaseError.PRODUCT_NOT_FOUND("undo not possible without purchases");
+ throw new DatabaseError.PRODUCT_NOT_FOUND(_("undo not possible without purchases"));
default:
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
statements["undo"].reset();
@@ -497,7 +497,7 @@ public class DataBase : Object {
rc = statements["undo"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
return pname;
}
@@ -524,7 +524,7 @@ public class DataBase : Object {
rc = statements["stock"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
public void new_product(uint64 id, string name, int category, int memberprice, int guestprice) throws DBusError, IOError, DatabaseError {
@@ -538,7 +538,7 @@ public class DataBase : Object {
if(rc == Sqlite.CONSTRAINT) {
throw new DatabaseError.CONSTRAINT_FAILED(db.errmsg());
} else if(rc != Sqlite.DONE) {
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
new_price(id, 0, memberprice, guestprice);
@@ -553,7 +553,7 @@ public class DataBase : Object {
int rc = statements["price_create"].step();
if(rc != Sqlite.DONE) {
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -580,7 +580,7 @@ public class DataBase : Object {
statements["user_auth_create"].bind_int(1, user);
rc = statements["user_auth_create"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
/* set password */
statements["password_set"].reset();
@@ -588,7 +588,7 @@ public class DataBase : Object {
statements["password_set"].bind_int(2, user);
rc = statements["password_set"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
public void set_sessionid(int user, string sessionid) throws DBusError, IOError, DatabaseError {
@@ -598,7 +598,7 @@ public class DataBase : Object {
int rc = statements["session_set"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
public int get_user_by_sessionid(string sessionid) throws DBusError, IOError, DatabaseError {
@@ -608,7 +608,7 @@ public class DataBase : Object {
if(statements["session_get"].step() == Sqlite.ROW) {
return statements["session_get"].column_int(0);
} else {
- throw new DatabaseError.SESSION_NOT_FOUND("No such session available in database!");
+ throw new DatabaseError.SESSION_NOT_FOUND(_("No such session available in database!"));
}
}
@@ -633,9 +633,9 @@ public class DataBase : Object {
result.soundTheme = statements["userinfo"].column_text(10);
result.joined_at = statements["userinfo"].column_int64(11);
} else if(rc == Sqlite.DONE) {
- throw new DatabaseError.USER_NOT_FOUND("user not found");
+ throw new DatabaseError.USER_NOT_FOUND(_("user not found"));
} else {
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
statements["rfid_userid"].reset();
@@ -672,7 +672,7 @@ public class DataBase : Object {
} else if(rc == Sqlite.DONE) {
/* entry not found, we return defaults */
} else {
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
return result;
@@ -686,7 +686,7 @@ public class DataBase : Object {
statements["user_auth_create"].bind_int(1, auth.id);
rc = statements["user_auth_create"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
/* set authentication */
statements["userauth_set"].reset();
@@ -697,7 +697,7 @@ public class DataBase : Object {
rc = statements["userauth_set"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
public string get_username(int user) throws DBusError, IOError, DatabaseError {
@@ -707,7 +707,7 @@ public class DataBase : Object {
if(statements["username"].step() == Sqlite.ROW) {
return statements["username"].column_text(0)+" "+statements["username"].column_text(1);
} else {
- throw new DatabaseError.USER_NOT_FOUND("No such user available in database!");
+ throw new DatabaseError.USER_NOT_FOUND(_("No such user available in database!"));
}
}
@@ -719,7 +719,7 @@ public class DataBase : Object {
if(statements["user_theme_get"].step() == Sqlite.ROW) {
return statements["user_theme_get"].column_text(0);
} else {
- throw new DatabaseError.USER_NOT_FOUND("No such user available in database!");
+ throw new DatabaseError.USER_NOT_FOUND(_("No such user available in database!"));
}
}
@@ -734,7 +734,7 @@ public class DataBase : Object {
int rc = statements["user_theme_set"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
public InvoiceEntry[] get_invoice(int user, int64 from=0, int64 to=-1) throws DBusError, IOError, DatabaseError {
@@ -762,7 +762,7 @@ public class DataBase : Object {
}
if(rc != Sqlite.DONE) {
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
return result;
@@ -881,7 +881,7 @@ public class DataBase : Object {
statements["user_auth_create"].bind_int(1, user);
rc = statements["user_auth_create"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
/* set disabled flag */
statements["user_disable"].reset();
@@ -889,7 +889,7 @@ public class DataBase : Object {
statements["user_disable"].bind_int(2, user);
rc = statements["user_disable"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
public void user_replace(UserInfo u) throws DBusError, IOError, DatabaseError {
@@ -910,13 +910,13 @@ public class DataBase : Object {
int rc = statements["user_replace"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
statements["rfid_delete_user"].reset();
statements["rfid_delete_user"].bind_int(1, u.id);
rc = statements["rfid_delete_user"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
foreach (string rfid in u.rfid) {
statements["rfid_insert"].reset();
@@ -924,7 +924,7 @@ public class DataBase : Object {
statements["rfid_insert"].bind_text(2, rfid);
rc = statements["rfid_insert"].step();
if(rc != Sqlite.DONE)
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -1025,7 +1025,7 @@ public class DataBase : Object {
int rc = statements["supplier_add"].step();
if(rc != Sqlite.DONE) {
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -1076,7 +1076,7 @@ public class DataBase : Object {
int rc = statements["cashbox_add"].step();
if(rc != Sqlite.DONE) {
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -1126,7 +1126,7 @@ public class DataBase : Object {
int rc = statements["alias_ean_add"].step();
if(rc != Sqlite.DONE) {
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
@@ -1207,9 +1207,9 @@ public class DataBase : Object {
case Sqlite.ROW:
return statements["userid_rfid"].column_int(0);
case Sqlite.DONE:
- throw new DatabaseError.RFID_NOT_FOUND("unknown rfid: %s", rfid);
+ throw new DatabaseError.RFID_NOT_FOUND(_("unknown rfid: %s"), rfid);
default:
- throw new DatabaseError.INTERNAL_ERROR("internal error: %d", rc);
+ throw new DatabaseError.INTERNAL_ERROR(_("internal error: %d"), rc);
}
}
}
diff --git a/src/database/main.vala b/src/database/main.vala
index f65707b..bd4c7dc 100644
--- a/src/database/main.vala
+++ b/src/database/main.vala
@@ -13,42 +13,41 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-public static void write_to_log(string message, ...) {
- /* TODO: send message via DBus? Replace some write_to_log by throwing an error? */
-}
-
DataBase db;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
try {
Config cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
var dbfile = cfg.get_string("DATABASE", "file");
db = new DataBase(dbfile);
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
} catch(KeyFileError e) {
- error("Config Error: %s\n", e.message);
+ error(_("Config Error: %s\n"), e.message);
} catch(DBusError e) {
- error("DBusError: %s\n", e.message);
+ error(_("DBus Error: %s\n"), e.message);
}
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.Database",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
con.register_object("/io/mainframe/shopsystem/database", db);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/input-device/Makefile b/src/input-device/Makefile
index aba6c73..5e501df 100644
--- a/src/input-device/Makefile
+++ b/src/input-device/Makefile
@@ -2,7 +2,7 @@ all: input-device
@echo > /dev/null
input-device: main.vala input-device.vala input-device-interface.vala ../config/config-interface.vala
- valac -X -w -o $@ --pkg linux --pkg posix --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg linux --pkg posix --pkg gio-2.0 $^
clean:
rm -rf input-device
diff --git a/src/input-device/input-device.vala b/src/input-device/input-device.vala
index 1c558d0..1dba213 100644
--- a/src/input-device/input-device.vala
+++ b/src/input-device/input-device.vala
@@ -24,7 +24,7 @@ public class Device {
public Device(string device) {
if (device == "ignore") {
- stdout.printf("Ignoring InputDevice!\n");
+ stdout.printf(_("Ignoring InputDevice!\n"));
return;
}
try {
@@ -37,10 +37,10 @@ public class Device {
Posix.fcntl(fd, Posix.F_SETFL, flags | Posix.O_NONBLOCK);
if(!(io_read.add_watch(IOCondition.IN | IOCondition.HUP, device_read) != 0)) {
- error("Could not bind IOChannel");
+ error(_("Could not bind IOChannel"));
}
} catch(FileError e) {
- error("FileError: %s", e.message);
+ error(_("File Error: %s"), e.message);
}
}
@@ -212,7 +212,7 @@ public class Device {
char key = '\0';
if((cond & IOCondition.HUP) == IOCondition.HUP)
- error("Lost device");
+ error(_("Lost device"));
do {
int fd = source.unix_get_fd();
@@ -221,7 +221,7 @@ public class Device {
/* short read */
if (s != sizeof(Linux.Input.Event)) {
if(s > 0)
- stdout.printf("short read!\n");
+ stdout.printf(_("short read!\n"));
return true;
}
@@ -246,7 +246,7 @@ public class Device {
buffer += "%c".printf(key);
} while(key != '\n');
- stdout.printf("barcode: %s\n", buffer);
+ stdout.printf(_("barcode: %s\n"), buffer);
if(buffer.has_prefix("USER ") || buffer.has_prefix("STOCK") || buffer.has_prefix("AMOUNT ")) {
if(!check_code39_checksum(buffer))
diff --git a/src/input-device/main.vala b/src/input-device/main.vala
index 372418e..487c028 100644
--- a/src/input-device/main.vala
+++ b/src/input-device/main.vala
@@ -18,40 +18,43 @@ Device devScanner;
Device devRfid;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
try {
Config cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
devScanner = new Device(cfg.get_string("INPUT", "barcodescanner"));
devRfid = new Device(cfg.get_string("INPUT", "rfidreader"));
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
} catch(KeyFileError e) {
- error("Config Error: %s\n", e.message);
+ error(_("Config Error: %s\n"), e.message);
} catch(DBusError e) {
- error("DBus Error: %s\n", e.message);
+ error(_("DBus Error: %s\n"), e.message);
}
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.InputDevice",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
con.register_object("/io/mainframe/shopsystem/device/scanner", devScanner);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
try {
con.register_object("/io/mainframe/shopsystem/device/rfid", devRfid);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/invoice/Makefile b/src/invoice/Makefile
index 73eaf48..d8d72c0 100644
--- a/src/invoice/Makefile
+++ b/src/invoice/Makefile
@@ -2,10 +2,10 @@ all: invoice single-invoice
@echo > /dev/null
invoice: main.vala invoice.vala ../mail/mailer-interface.vala ../pdf-invoice/pdf-invoice-interface.vala ../database/db-interface.vala ../config/config-interface.vala ../price.vapi
- valac -X -w -o $@ --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg gio-2.0 $^
single-invoice: single.vala invoice.vala ../mail/mailer-interface.vala ../pdf-invoice/pdf-invoice-interface.vala ../database/db-interface.vala ../config/config-interface.vala ../price.vapi
- valac -X -w -o $@ --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg gio-2.0 $^
clean:
rm -f invoice single-invoice
diff --git a/src/invoice/invoice.vala b/src/invoice/invoice.vala
index c0a162c..f899cb5 100644
--- a/src/invoice/invoice.vala
+++ b/src/invoice/invoice.vala
@@ -249,7 +249,7 @@ public class InvoiceImplementation {
try {
FileUtils.get_contents(datadir + "/treasurer.mail.txt", out text);
} catch(GLib.FileError e) {
- throw new IOError.FAILED("Could not open invoice template: %s", e.message);
+ throw new IOError.FAILED(_("Could not open invoice template: %s"), e.message);
}
text = text.replace("{{{SHORTNAME}}}", shortname);
@@ -311,12 +311,12 @@ public class InvoiceImplementation {
table = generate_invoice_table_html(entries);
if(filename == "")
- throw new IOError.FAILED("Unknown MessageType");
+ throw new IOError.FAILED(_("Unknown MessageType"));
try {
FileUtils.get_contents(datadir + "/" + filename, out text);
} catch(GLib.FileError e) {
- throw new IOError.FAILED("Could not open invoice template: %s", e.message);
+ throw new IOError.FAILED(_("Could not open invoice template: %s"), e.message);
}
text = text.replace("{{{ADDRESS}}}", address);
@@ -335,7 +335,7 @@ public class InvoiceImplementation {
try {
FileUtils.get_contents(datadir + "/" + vattextfilename, out vattext);
} catch(GLib.FileError e) {
- throw new IOError.FAILED("Could not open VAT template: %s", e.message);
+ throw new IOError.FAILED(_("Could not open VAT template: %s"), e.message);
}
text = text.replace("{{{VAT}}}", vattext);
diff --git a/src/invoice/main.vala b/src/invoice/main.vala
index b341adb..f5ec69b 100644
--- a/src/invoice/main.vala
+++ b/src/invoice/main.vala
@@ -16,11 +16,14 @@
InvoiceImplementation invoice;
public static void help(string name) {
- stderr.printf("Usage: %s <temporary> [timestamp]\n", name);
- stderr.printf("Possible values for <temporary>: temporary, final\n");
+ stderr.printf(_("Usage: %s <temporary> [timestamp]\n"), name);
+ stderr.printf(_("Possible values for <temporary>: temporary, final\n"));
}
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
bool temporary = false;
int64 timestamp = new DateTime.now_local().to_unix();
@@ -45,14 +48,14 @@ public static int main(string[] args) {
try {
invoice = new InvoiceImplementation();
} catch(Error e) {
- stderr.printf("Error: %s\n", e.message);
+ stderr.printf(_("Error: %s\n"), e.message);
return 1;
}
try {
invoice.send_invoices(temporary, timestamp);
} catch(Error e) {
- stderr.printf("Error: %s\n", e.message);
+ stderr.printf(_("Error: %s\n"), e.message);
return 1;
}
diff --git a/src/invoice/single.vala b/src/invoice/single.vala
index 54cba26..6f54afe 100644
--- a/src/invoice/single.vala
+++ b/src/invoice/single.vala
@@ -48,14 +48,14 @@ public static int main(string[] args) {
try {
invoice = new InvoiceImplementation();
} catch(Error e) {
- stderr.printf("Error: %s\n", e.message);
+ stderr.printf(_("Error: %s\n"), e.message);
return 1;
}
try {
invoice.send_invoice(temporary, timestamp, user);
} catch(Error e) {
- stderr.printf("Error: %s\n", e.message);
+ stderr.printf(_("Error: %s\n"), e.message);
return 1;
}
diff --git a/src/mail/Makefile b/src/mail/Makefile
index 47819dd..70e9b5a 100644
--- a/src/mail/Makefile
+++ b/src/mail/Makefile
@@ -2,7 +2,7 @@ all: mailer
@echo > /dev/null
mailer: main.vala mailer.vala mail.vala mailer-interface.vala ../config/config-interface.vala
- valac -X -w -o $@ --vapidir=../../vapi --pkg posix --pkg libesmtp --pkg gio-2.0 --pkg gmime-3.0 -X -D_GNU_SOURCE -X -lesmtp -X -lssl -X -lcrypto -X -ldl -X -pthread $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --vapidir=../../vapi --pkg posix --pkg libesmtp --pkg gio-2.0 --pkg gmime-3.0 -X -D_GNU_SOURCE -X -lesmtp -X -lssl -X -lcrypto -X -ldl -X -pthread $^
clean:
rm -f mailer
diff --git a/src/mail/mailer.vala b/src/mail/mailer.vala
index c8d609c..3d7a996 100644
--- a/src/mail/mailer.vala
+++ b/src/mail/mailer.vala
@@ -76,7 +76,7 @@ public class MailerImplementation {
var cfgport = config.get_integer("MAIL", "port");
server = @"$cfgserv:$cfgport";
} catch(KeyFileError e) {
- throw new IOError.FAILED("server or port configuration is missing");
+ throw new IOError.FAILED(_("server or port configuration is missing"));
}
try {
@@ -96,7 +96,7 @@ public class MailerImplementation {
/* setup server */
result = session.set_server(server);
if(result == 0)
- throw new IOError.FAILED("could not setup server");
+ throw new IOError.FAILED(_("could not setup server"));
/* Use TLS if possible */
if (starttls)
@@ -104,7 +104,7 @@ public class MailerImplementation {
else
result = session.starttls_enable(Smtp.StartTlsOption.DISABLED);
if(result == 0)
- throw new IOError.FAILED("could not configure STARTTLS");
+ throw new IOError.FAILED(_("could not configure STARTTLS"));
/* setup authentication */
if(username != "") {
@@ -138,7 +138,7 @@ public class MailerImplementation {
public void delete_mail(string path) throws DBusError, IOError {
if(!(path in mails))
- throw new IOError.NOT_FOUND("No such mail");
+ throw new IOError.NOT_FOUND(_("No such mail"));
mail_bus.unregister_object(mails[path].registration_id);
mails.remove(path);
@@ -146,7 +146,7 @@ public class MailerImplementation {
public void send_mail(string path) throws DBusError, IOError {
if(!(path in mails))
- throw new IOError.NOT_FOUND("No such mail");
+ throw new IOError.NOT_FOUND(_("No such mail"));
send_queue.push_tail(mails[path].mail);
delete_mail(path);
@@ -173,11 +173,11 @@ public class MailerImplementation {
int result = session.start_session();
if(result == 0)
- throw new IOError.FAILED("eSMTP: Start Session failed!");
+ throw new IOError.FAILED(_("eSMTP: Start Session failed!"));
unowned Smtp.Status status = message.transfer_status();
if(status.code < 200 || status.code >= 300)
- throw new IOError.FAILED("Reply from SMTP-Server: %s", status.text);
+ throw new IOError.FAILED(_("Reply from SMTP-Server: %s"), status.text);
current_mail = null;
diff --git a/src/mail/main.vala b/src/mail/main.vala
index 989c4f1..b3a7088 100644
--- a/src/mail/main.vala
+++ b/src/mail/main.vala
@@ -17,30 +17,33 @@ MailerImplementation m;
DBusConnection mail_bus;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
try {
m = new MailerImplementation();
} catch(Error e) {
- stderr.printf("Error: %s\n", e.message);
+ stderr.printf(_("Error: %s\n"), e.message);
}
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.Mail",
BusNameOwnerFlags.NONE,
- on_mail_bus_aquired,
+ on_mail_bus_acquired,
() => {},
- () => stderr.printf("Error: Could not aquire name\n"));
+ () => stderr.printf(_("Error: Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_mail_bus_aquired(DBusConnection con) {
+void on_mail_bus_acquired(DBusConnection con) {
try {
mail_bus = con;
con.register_object("/io/mainframe/shopsystem/mailer", m);
} catch(IOError e) {
- stderr.printf("Error: Could not register service\n");
+ stderr.printf(_("Error: Could not register service\n"));
}
}
diff --git a/src/pdf-invoice/Makefile b/src/pdf-invoice/Makefile
index 9805f6e..91b8522 100644
--- a/src/pdf-invoice/Makefile
+++ b/src/pdf-invoice/Makefile
@@ -2,10 +2,10 @@ all: pdf-invoice
@echo > /dev/null
pdf-invoice: main.vala pdf-invoice.vala pdf-invoice-interface.vala ../config/config-interface.vala ../database/db-interface.vala ../price.vapi
- valac -X -w -g -o $@ --pkg pangocairo --pkg librsvg-2.0 --pkg posix --pkg gdk-2.0 --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -g -o $@ --pkg pangocairo --pkg librsvg-2.0 --pkg posix --pkg gdk-2.0 --pkg gio-2.0 $^
test: pdf-invoice-interface.vala ../database/db-interface.vala test.vala ../price.vapi
- valac -X -w -o $@ --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg gio-2.0 $^
clean:
rm -rf pdf-invoice test
diff --git a/src/pdf-invoice/main.vala b/src/pdf-invoice/main.vala
index dc95bde..1848852 100644
--- a/src/pdf-invoice/main.vala
+++ b/src/pdf-invoice/main.vala
@@ -16,34 +16,37 @@
private string datadir;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
try {
Config cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
datadir = cfg.get_string("INVOICE", "datadir");
} catch(DBusError e) {
- error("DBusError: %s\n", e.message);
+ error(_("DBus Error: %s\n"), e.message);
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
} catch(KeyFileError e) {
- error("Config Error: %s\n", e.message);
+ error(_("Config Error: %s\n"), e.message);
}
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.InvoicePDF",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_bus_aquired(DBusConnection conn) {
+void on_bus_acquired(DBusConnection conn) {
try {
conn.register_object("/io/mainframe/shopsystem/invoicepdf", new InvoicePDF(datadir));
} catch(Error e) {
- stderr.printf("Could not register service: %s\n", e.message);
+ stderr.printf(_("Could not register service: %s\n"), e.message);
}
}
diff --git a/src/pdf-invoice/pdf-invoice.vala b/src/pdf-invoice/pdf-invoice.vala
index d92c93f..b41817d 100644
--- a/src/pdf-invoice/pdf-invoice.vala
+++ b/src/pdf-invoice/pdf-invoice.vala
@@ -78,7 +78,7 @@ public class InvoicePDF {
var svg = new Rsvg.Handle.from_file(file);
svg.render_cairo(ctx);
} catch(Error e) {
- error("Could not load SVG: %s\n", e.message);
+ error(_("Could not load SVG: %s\n"), e.message);
}
}
@@ -376,7 +376,7 @@ public class InvoicePDF {
try {
FileUtils.get_contents(datadir + "/" + "vat.txt", out vattext);
} catch(GLib.FileError e) {
- throw new IOError.FAILED("Could not open VAT template: %s", e.message);
+ throw new IOError.FAILED(_("Could not open VAT template: %s"), e.message);
}
text = text.replace("{{{VAT}}}", vattext);
@@ -384,7 +384,7 @@ public class InvoicePDF {
layout.set_markup(text, text.length);
} catch(GLib.FileError e) {
- error("File Error: %s\n", e.message);
+ error(_("File Error: %s\n"), e.message);
}
/* render text */
@@ -468,11 +468,11 @@ public class InvoicePDF {
var price = @"$(e.price)€".replace(".", ",");
if(e.price > 999999) {
- throw new InvoicePDFError.PRICE_TOO_HIGH("Prices > 9999.99€ are not supported!");
+ throw new InvoicePDFError.PRICE_TOO_HIGH(_("Prices > 9999.99€ are not supported!"));
}
if(tm.get_year() > 9999) {
- throw new InvoicePDFError.TOO_FAR_IN_THE_FUTURE("Years after 9999 are not supported!");
+ throw new InvoicePDFError.TOO_FAR_IN_THE_FUTURE(_("Years after 9999 are not supported!"));
}
/* if date remains the same do not add it again */
@@ -588,7 +588,7 @@ public class InvoicePDF {
/* retry adding the entry */
if(!draw_invoice_table_entry(ctx, y, entry, out y)) {
- throw new InvoicePDFError.ARTICLE_NAME_TOO_LONG("Article name \"%s\" does not fit on a single page!", entry.product.name);
+ throw new InvoicePDFError.ARTICLE_NAME_TOO_LONG(_("Article name \"%s\" does not fit on a single page!"), entry.product.name);
}
}
}
@@ -625,16 +625,16 @@ public class InvoicePDF {
var ctx = new Cairo.Context(document);
if(invoice_id == "")
- throw new InvoicePDFError.NO_INVOICE_ID("No invoice ID given!");
+ throw new InvoicePDFError.NO_INVOICE_ID(_("No invoice ID given!"));
if(invoice_entries == null)
- throw new InvoicePDFError.NO_INVOICE_DATA("No invoice data given!");
+ throw new InvoicePDFError.NO_INVOICE_DATA(_("No invoice data given!"));
if(invoice_date == 0)
- throw new InvoicePDFError.NO_INVOICE_DATE("No invoice date given!");
+ throw new InvoicePDFError.NO_INVOICE_DATE(_("No invoice date given!"));
if(invoice_recipient.firstname == "" && invoice_recipient.lastname == "")
- throw new InvoicePDFError.NO_INVOICE_RECIPIENT("No invoice recipient given!");
+ throw new InvoicePDFError.NO_INVOICE_RECIPIENT(_("No invoice recipient given!"));
/* first page */
draw_logo(ctx);
diff --git a/src/pdf-stock/Makefile b/src/pdf-stock/Makefile
index 2c8be58..c310c65 100644
--- a/src/pdf-stock/Makefile
+++ b/src/pdf-stock/Makefile
@@ -6,10 +6,10 @@ all: pdf-stock
@echo > /dev/null
pdf-stock: main.vala pdf-stock.vala ../database/db-interface.vala ../price.vapi ../../libcairobarcode/libcairobarcode.vapi
- ${VALAC} -X -w ${LIBCAIROBARCODE} -o $@ --pkg cairo --pkg pangocairo --pkg gio-2.0 --pkg posix $^
+ ${VALAC} -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w ${LIBCAIROBARCODE} -o $@ --pkg cairo --pkg pangocairo --pkg gio-2.0 --pkg posix $^
test: test.vala pdf-stock-interface.vala
- ${VALAC} -X -w -o $@ --pkg gio-2.0 $^
+ ${VALAC} -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg gio-2.0 $^
run: pdf-stock
LD_LIBRARY_PATH=../../libcairobarcode ./pdf-stock
diff --git a/src/pdf-stock/main.vala b/src/pdf-stock/main.vala
index 49613f4..10aef60 100644
--- a/src/pdf-stock/main.vala
+++ b/src/pdf-stock/main.vala
@@ -14,23 +14,26 @@
*/
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.StockPDF",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_bus_aquired(DBusConnection conn) {
+void on_bus_acquired(DBusConnection conn) {
try {
conn.register_object("/io/mainframe/shopsystem/stockpdf", new StockPDF());
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/pdf-stock/test.vala b/src/pdf-stock/test.vala
index cc3da4f..2e35f9c 100644
--- a/src/pdf-stock/test.vala
+++ b/src/pdf-stock/test.vala
@@ -19,9 +19,11 @@ public static int main(string args[]) {
var pdfdata = stock.generate();
FileUtils.set_contents("test.pdf", (string) pdfdata, pdfdata.length);
} catch(IOError e) {
- error("IOError: %s", e.message);
+ error(_("IO Error: %s"), e.message);
} catch(FileError e) {
- error("FileError: %s", e.message);
+ error(_("File Error: %s"), e.message);
+ } catch(DBusError e) {
+ error(_("DBus Error: %s"), e.message);
}
return 0;
diff --git a/src/pgp/Makefile b/src/pgp/Makefile
index 6292111..5faa80f 100644
--- a/src/pgp/Makefile
+++ b/src/pgp/Makefile
@@ -2,7 +2,7 @@ all: pgp
@echo > /dev/null
pgp: main.vala pgp.vala pgp-interface.vala ../config/config-interface.vala
- valac --Xcc="-D_FILE_OFFSET_BITS=64" -X -w -o $@ --vapidir ../../vapi -X -lgpgme --pkg gpgme --pkg gio-2.0 --pkg libarchive $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' --Xcc="-D_FILE_OFFSET_BITS=64" -X -w -o $@ --vapidir ../../vapi -X -lgpgme --pkg gpgme --pkg gio-2.0 --pkg libarchive $^
clean:
rm -rf pgp
diff --git a/src/pgp/main.vala b/src/pgp/main.vala
index 332bcd5..74bcf0e 100644
--- a/src/pgp/main.vala
+++ b/src/pgp/main.vala
@@ -21,35 +21,37 @@ PGPKeyArchive pgp;
Config cfg;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
try {
cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
pgp = new PGPKeyArchive(cfg.get_string("PGP", "keyring"));
} catch(DBusError e) {
- error("DBusError: %s\n", e.message);
+ error(_("DBus Error: %s\n"), e.message);
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
} catch(KeyFileError e) {
- error("Config Error: %s\n", e.message);
+ error(_("Config Error: %s\n"), e.message);
}
-
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.PGP",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
con.register_object("/io/mainframe/shopsystem/pgp", pgp);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/pgp/pgp.vala b/src/pgp/pgp.vala
index 2a5b160..6d9bed0 100644
--- a/src/pgp/pgp.vala
+++ b/src/pgp/pgp.vala
@@ -120,7 +120,7 @@ public class PGPKeyArchive {
keydata.read(data);
return (string) data;
} else {
- stdout.printf("error!\n");
+ stdout.printf(_("Error!\n"));
return "";
}
}
diff --git a/src/scanner-session/Makefile b/src/scanner-session/Makefile
index 5320025..28f0ea8 100644
--- a/src/scanner-session/Makefile
+++ b/src/scanner-session/Makefile
@@ -2,7 +2,7 @@ all: scanner-session
@echo > /dev/null
scanner-session: main.vala scannersession.vala scannersession-interface.vala ../database/db-interface.vala ../input-device/input-device-interface.vala ../cli/cli-interface.vala ../audio/audio-interface.vala ../price.vapi
- valac -X -w -o $@ --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg gio-2.0 $^
clean:
rm -rf scanner-session
diff --git a/src/scanner-session/main.vala b/src/scanner-session/main.vala
index 2ed94f9..3b876c5 100644
--- a/src/scanner-session/main.vala
+++ b/src/scanner-session/main.vala
@@ -16,13 +16,16 @@
ScannerSessionImplementation session;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.ScannerSession",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
session = new ScannerSessionImplementation();
@@ -31,10 +34,10 @@ public static int main(string[] args) {
return 0;
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
con.register_object("/io/mainframe/shopsystem/scanner_session", session);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/scanner-session/scannersession.vala b/src/scanner-session/scannersession.vala
index fc385f6..cf308ce 100644
--- a/src/scanner-session/scannersession.vala
+++ b/src/scanner-session/scannersession.vala
@@ -17,7 +17,7 @@
[DBus (name = "io.mainframe.shopsystem.ScannerSession")]
public class ScannerSessionImplementation {
private int user = 0;
- private string name = "Guest";
+ private string name = _("Guest");
private bool logged_in = false;
private bool disabled = false;
private string theme = "beep";
@@ -46,7 +46,7 @@ public class ScannerSessionImplementation {
devRfid.received_barcode.connect(handle_barcode);
cli.received_barcode.connect(handle_barcode);
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
}
}
@@ -63,7 +63,7 @@ public class ScannerSessionImplementation {
this.name = db.get_username(user);
this.disabled = db.user_is_disabled(user);
} catch(DatabaseError e) {
- send_message(MessageType.ERROR, "Error (user=%d): %s", user, e.message);
+ send_message(MessageType.ERROR, _("Error (user=%d): %s"), user, e.message);
return false;
}
this.logged_in = true;
@@ -132,13 +132,13 @@ public class ScannerSessionImplementation {
int32 userid = int.parse(scannerdata.substring(5));
if(login(userid)) {
scannerResult.type = MessageType.INFO;
- scannerResult.message = "Login: %s (%d)".printf(name, user);
+ scannerResult.message = _("Login: %s (%d)").printf(name, user);
scannerResult.audioType = AudioType.LOGIN;
shoppingCard = {};
state = ScannerSessionState.USER;
} else {
scannerResult.type = MessageType.ERROR;
- scannerResult.message = "Login failed (User ID = %d)".printf(userid);
+ scannerResult.message = _("Login failed (User ID = %d)").printf(userid);
scannerResult.audioType = AudioType.ERROR;
state = ScannerSessionState.READY;
}
@@ -146,13 +146,13 @@ public class ScannerSessionImplementation {
case ScannerSessionCodeType.GUEST:
if(login(0)) {
scannerResult.type = MessageType.INFO;
- scannerResult.message = "Login as GUEST";
+ scannerResult.message = _("Login as GUEST");
scannerResult.audioType = AudioType.LOGIN;
shoppingCard = {};
state = ScannerSessionState.USER;
} else {
scannerResult.type = MessageType.ERROR;
- scannerResult.message = "Login failed as GUEST";
+ scannerResult.message = _("Login failed as GUEST");
scannerResult.audioType = AudioType.ERROR;
state = ScannerSessionState.READY;
}
@@ -165,17 +165,17 @@ public class ScannerSessionImplementation {
p = db.get_product_for_ean(ean);
} catch(IOError e) {
scannerResult.type = MessageType.ERROR;
- scannerResult.message = "Internal Error!";
+ scannerResult.message = _("Internal Error!");
scannerResult.audioType = AudioType.ERROR;
return scannerResult;
} catch(DatabaseError e) {
if(e is DatabaseError.PRODUCT_NOT_FOUND) {
scannerResult.type = MessageType.ERROR;
- scannerResult.message = "Error: unknown product: %llu".printf(ean);
+ scannerResult.message = _("Error: unknown product: %llu").printf(ean);
scannerResult.audioType = AudioType.ERROR;
} else {
scannerResult.type = MessageType.ERROR;
- scannerResult.message = "Error: %s".printf(e.message);
+ scannerResult.message = _("Error: %s").printf(e.message);
scannerResult.audioType = AudioType.ERROR;
}
return scannerResult;
@@ -186,13 +186,13 @@ public class ScannerSessionImplementation {
var pname = p.name;
scannerResult.type = MessageType.INFO;
- scannerResult.message = @"article info: $pname (Member: $mprice €, Guest: $gprice €)";
+ scannerResult.message = _("article info: %s (Member: %s €, Guest: %s €").printf(@"$pname", @"$mprice", @"$gprice");
scannerResult.audioType = AudioType.ERROR;
state = ScannerSessionState.READY;
return scannerResult;
case ScannerSessionCodeType.RFIDEM4100:
int user = db.get_userid_for_rfid(scannerdata);
- scannerResult.nextScannerdata =@"USER $user";
+ scannerResult.nextScannerdata = @"USER $user";
return scannerResult;
default:
state = ScannerSessionState.READY;
@@ -212,17 +212,17 @@ public class ScannerSessionImplementation {
p = db.get_product_for_ean(ean);
} catch(IOError e) {
scannerResult.type = MessageType.ERROR;
- scannerResult.message = "Internal Error!";
+ scannerResult.message = _("Internal Error!");
scannerResult.audioType = AudioType.ERROR;
return scannerResult;
} catch(DatabaseError e) {
if(e is DatabaseError.PRODUCT_NOT_FOUND) {
scannerResult.type = MessageType.ERROR;
- scannerResult.message = "Error: unknown product: %llu".printf(ean);
+ scannerResult.message = _("Error: unknown product: %llu").printf(ean);
scannerResult.audioType = AudioType.ERROR;
} else {
scannerResult.type = MessageType.ERROR;
- scannerResult.message = "Error: %s".printf(e.message);
+ scannerResult.message = _("Error: %s").printf(e.message);
scannerResult.audioType = AudioType.ERROR;
}
return scannerResult;
@@ -237,7 +237,7 @@ public class ScannerSessionImplementation {
}
scannerResult.type = MessageType.INFO;
- scannerResult.message = @"article added to shopping card: $(p.name) ($price €)";
+ scannerResult.message = _("article added to shopping card: %s (%s €)").printf(@"$(p.name)", @"$price");
scannerResult.audioType = AudioType.PURCHASE;
state = ScannerSessionState.USER;
break;
@@ -246,11 +246,11 @@ public class ScannerSessionImplementation {
var removedProduct = shoppingCard[shoppingCard.length-1];
shoppingCard = shoppingCard[0:shoppingCard.length-1];
scannerResult.type = MessageType.INFO;
- scannerResult.message = @"removed last Item from Shopping Cart: $(removedProduct.name)";
+ scannerResult.message = _("removed last Item from Shopping Cart: %s").printf(@"$(removedProduct.name)");
scannerResult.audioType = AudioType.INFO;
} else {
scannerResult.type = MessageType.INFO;
- scannerResult.message = @"No more Items on your Shopping Cart";
+ scannerResult.message = _("No more Items on your Shopping Cart");
scannerResult.audioType = AudioType.ERROR;
}
break;
@@ -286,7 +286,7 @@ public class ScannerSessionImplementation {
totalPrice += price;
}
scannerResult.type = MessageType.INFO;
- scannerResult.message = @"$name bought $amountOfItems items for $totalPrice €";
+ scannerResult.message = @_("%s bought %d items for %s €").printf(@"$name", amountOfItems, @"$totalPrice");
scannerResult.audioType = AudioType.INFO;
return scannerResult;
}
@@ -297,11 +297,11 @@ public class ScannerSessionImplementation {
if(interpret(scannerdata))
devScanner.blink(1000);
} catch(DBusError e) {
- send_message(MessageType.ERROR, "DBusError: %s", e.message);
+ send_message(MessageType.ERROR, _("DBus Error: %s"), e.message);
} catch(IOError e) {
- send_message(MessageType.ERROR, "IOError: %s", e.message);
+ send_message(MessageType.ERROR, _("IO Error: %s"), e.message);
} catch(DatabaseError e) {
- send_message(MessageType.ERROR, "DatabaseError: %s", e.message);
+ send_message(MessageType.ERROR, _("Database Error: %s"), e.message);
}
}
@@ -331,6 +331,4 @@ public class ScannerSessionImplementation {
state = ScannerSessionState.READY;
return scannerResult;
}
-
-
}
diff --git a/src/serial-device/Makefile b/src/serial-device/Makefile
index d80279d..9c810ea 100644
--- a/src/serial-device/Makefile
+++ b/src/serial-device/Makefile
@@ -2,7 +2,7 @@ all: serial-device
@echo > /dev/null
serial-device: main.vala serial-device.vala ../input-device/input-device-interface.vala ../config/config-interface.vala
- valac -X -w -o $@ --pkg linux --pkg posix --pkg gio-2.0 $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --pkg linux --pkg posix --pkg gio-2.0 $^
clean:
rm -rf serial-device
diff --git a/src/serial-device/main.vala b/src/serial-device/main.vala
index 5d5a107..95926b5 100644
--- a/src/serial-device/main.vala
+++ b/src/serial-device/main.vala
@@ -17,34 +17,37 @@
Device scanner;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
try {
Config cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
scanner = new Device(cfg.get_string("INPUT", "barcodescanner"), 9600, 8, 1);
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
} catch(KeyFileError e) {
- error("Config Error: %s\n", e.message);
+ error(_("Config Error: %s\n"), e.message);
} catch(DBusError e) {
- error("DBus Error: %s\n", e.message);
+ error(_("DBus Error: %s\n"), e.message);
}
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.InputDevice",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
con.register_object("/io/mainframe/shopsystem/devicescanner", scanner);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/serial-device/serial-device.vala b/src/serial-device/serial-device.vala
index ae7480b..3900128 100644
--- a/src/serial-device/serial-device.vala
+++ b/src/serial-device/serial-device.vala
@@ -36,11 +36,11 @@ public class Device {
if(lockfile.load_contents(null, out data, null)) {
pid = int.parse((string) data);
} else {
- error("Can't read lock file!\n");
+ error(_("Can't read lock file!\n"));
}
if(Posix.kill(pid, 0) == 0) {
- error("serial device is locked!\n");
+ error(_("serial device is locked!\n"));
}
}
@@ -52,11 +52,11 @@ public class Device {
if(fd < 0) {
fd = -1;
lockfile.delete();
- error("Could not open device!\n");
+ error(_("Could not open device!\n"));
}
} catch(Error e) {
- error("Could not create lock file: %s!\n", e.message);
+ error(_("Could not create lock file: %s!\n"), e.message);
}
@@ -160,12 +160,12 @@ public class Device {
io_read = new IOChannel.unix_new(fd);
io_read.set_line_term("\r\n", 2);
if(io_read.set_encoding(null) != IOStatus.NORMAL)
- error("Failed to set encoding");
+ error(_("Failed to set encoding"));
if(!(io_read.add_watch(IOCondition.IN | IOCondition.HUP, device_read) != 0)) {
- error("Could not bind IOChannel");
+ error(_("Could not bind IOChannel"));
}
} catch(IOChannelError e) {
- error("IOChannel: %s", e.message);
+ error(_("IOChannel: %s"), e.message);
}
}
@@ -186,7 +186,7 @@ public class Device {
size_t len, term_char;
if((cond & IOCondition.HUP) == IOCondition.HUP)
- error("Lost device");
+ error(_("Lost device"));
try {
ret = gio.read_line(out msg, out len, out term_char);
@@ -204,11 +204,11 @@ public class Device {
received_barcode(msg);
}
catch(IOChannelError e) {
- stderr.printf("IOChannel Error: %s", e.message);
+ stderr.printf(_("IOChannel Error: %s"), e.message);
return false;
}
catch(ConvertError e) {
- stderr.printf("Convert Error: %s", e.message);
+ stderr.printf(_("Convert Error: %s"), e.message);
return false;
}
return true;
diff --git a/src/web/Makefile b/src/web/Makefile
index e6094f6..22d7bbc 100644
--- a/src/web/Makefile
+++ b/src/web/Makefile
@@ -2,7 +2,7 @@ all: web
@echo > /dev/null
web: main.vala web.vala websession.vala csv.vala template.vala ../database/db-interface.vala ../pgp/pgp-interface.vala ../price.vapi ../config/config-interface.vala ../audio/audio-interface.vala
- valac -X -w -o $@ --vapidir=../../vapi --enable-experimental --pkg gee-0.8 --pkg gio-2.0 --pkg libsoup-2.4 --pkg posix $^
+ valac -X -D'GETTEXT_PACKAGE="shopsystem"' -X -w -o $@ --vapidir=../../vapi --enable-experimental --pkg gee-0.8 --pkg gio-2.0 --pkg libsoup-2.4 --pkg posix $^
clean:
rm -rf web
diff --git a/src/web/main.vala b/src/web/main.vala
index e249d81..f7b0c30 100644
--- a/src/web/main.vala
+++ b/src/web/main.vala
@@ -21,6 +21,9 @@ public AudioPlayer audio;
string templatedir;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
TlsCertificate? cert = null;
string certificate = "";
string privatekey = "";
@@ -30,7 +33,7 @@ public static int main(string[] args) {
db = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Database", "/io/mainframe/shopsystem/database");
pgp = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.PGP", "/io/mainframe/shopsystem/pgp");
cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
- audio = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.AudioPlayer", "/io/mainframe/shopsystem/audio");
+ audio = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.AudioPlayer", "/io/mainframe/shopsystem/audio");
templatedir = cfg.get_string("WEB", "filepath");
port = cfg.get_integer("WEB", "port");
@@ -38,19 +41,19 @@ public static int main(string[] args) {
certificate = cfg.get_string("WEB", "cert");
privatekey = cfg.get_string("WEB", "key");
} catch(KeyFileError e) {
- warning("KeyFileError: %s\n", e.message);
+ warning(_("KeyFile Error: %s\n"), e.message);
}
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
} catch(KeyFileError e) {
- error("KeyFileError: %s\n", e.message);
+ error(_("KeyFile Error: %s\n"), e.message);
} catch(DBusError e) {
- error("DBusError: %s\n", e.message);
+ error(_("DBus Error: %s\n"), e.message);
}
- stdout.printf("Web Server Port: %u\n", port);
- stdout.printf("TLS certificate: %s\n", certificate);
- stdout.printf("TLS private key: %s\n", privatekey);
+ stdout.printf(_("Web Server Port: %u\n"), port);
+ stdout.printf(_("TLS certificate: %s\n"), certificate);
+ stdout.printf(_("TLS private key: %s\n"), privatekey);
/* attach WebServer to MainLoop */
try {
@@ -58,7 +61,7 @@ public static int main(string[] args) {
cert = new TlsCertificate.from_files(certificate, privatekey);
new WebServer(port, cert);
} catch(Error e) {
- error("Could not start Webserver: %s\n", e.message);
+ error(_("Could not start Webserver: %s\n"), e.message);
}
/* start MainLoop */
diff --git a/src/web/template.vala b/src/web/template.vala
index b5265d8..f5c6d75 100644
--- a/src/web/template.vala
+++ b/src/web/template.vala
@@ -37,28 +37,28 @@ public class WebTemplate {
uint8[] basis, menu, template, auth;
if(!b.query_exists())
- throw new TemplateError.NOT_FOUND(templatedir+"base.html not found!");
+ throw new TemplateError.NOT_FOUND(_("%s not found!").printf(templatedir+"base.html"));
if(!m.query_exists())
- throw new TemplateError.NOT_FOUND(templatedir+"menu.html not found!");
+ throw new TemplateError.NOT_FOUND(_("%s not found!").printf(templatedir+"menu.html"));
if(!fauth.query_exists())
- throw new TemplateError.NOT_FOUND(fauth.get_path()+" not found!");
+ throw new TemplateError.NOT_FOUND(_("%s not found!").printf(fauth.get_path()));
if(!f.query_exists())
- throw new TemplateError.NOT_FOUND(templatedir+file+" not found!");
+ throw new TemplateError.NOT_FOUND(_("%s not found!").printf(templatedir+file));
try {
if(!b.load_contents(null, out basis, null))
- throw new TemplateError.NOT_LOADABLE(templatedir+"base.html could not be loaded!");
+ throw new TemplateError.NOT_LOADABLE(_("%s could not be loaded!").printf(templatedir+"base.html"));
if(!m.load_contents(null, out menu, null))
- throw new TemplateError.NOT_LOADABLE(templatedir+"menu.html could not be loaded!");
+ throw new TemplateError.NOT_LOADABLE(_("%s could not be loaded!").printf(templatedir+"menu.html"));
if(!fauth.load_contents(null, out auth, null))
- throw new TemplateError.NOT_LOADABLE(fauth.get_path()+" could not be loaded!");
+ throw new TemplateError.NOT_LOADABLE(_("%s could not be loaded!").printf(fauth.get_path()));
if(!f.load_contents(null, out template, null))
- throw new TemplateError.NOT_LOADABLE(templatedir+file+" could not be loaded!");
+ throw new TemplateError.NOT_LOADABLE(_("%s could not be loaded!").printf(templatedir+file));
} catch(Error e) {
- throw new TemplateError.NOT_LOADABLE("could not load templates!");
+ throw new TemplateError.NOT_LOADABLE(_("could not load templates!"));
}
this.template = ((string) basis).replace("{{{NAVBAR}}}", ((string) menu));
@@ -75,13 +75,13 @@ public class WebTemplate {
uint8[] template;
if(!f.query_exists())
- throw new TemplateError.NOT_FOUND(templatedir+file+" not found!");
+ throw new TemplateError.NOT_FOUND(_("%s not found!").printf(templatedir+file));
try {
if(!f.load_contents(null, out template, null))
- throw new TemplateError.NOT_LOADABLE(templatedir+file+" could not be loaded!");
+ throw new TemplateError.NOT_LOADABLE(_("%s could not be loaded!").printf(templatedir+file));
} catch(Error e) {
- throw new TemplateError.NOT_LOADABLE("could not load templates!");
+ throw new TemplateError.NOT_LOADABLE(_("could not load templates!"));
}
this.template = (string) template;
diff --git a/src/web/web.vala b/src/web/web.vala
index 695ec70..5524a7e 100644
--- a/src/web/web.vala
+++ b/src/web/web.vala
@@ -1140,7 +1140,7 @@ public class WebServer {
return;
}
} catch(Error e) {
- error("there has been some error: %s!\n", e.message);
+ error(_("Error: %s\n"), e.message);
}
handler_404(server, msg, path, query, client);
@@ -1479,7 +1479,7 @@ public class WebServer {
options |= Soup.ServerListenOptions.HTTPS;
if(!srv.listen_all(port, options)) {
- throw new GLib.IOError.FAILED("Could not setup webserver!");
+ throw new GLib.IOError.FAILED(_("Could not setup webserver!"));
}
/* index */
diff --git a/src/web/websession.vala b/src/web/websession.vala
index 839d0a2..85fd516 100644
--- a/src/web/websession.vala
+++ b/src/web/websession.vala
@@ -128,9 +128,9 @@ public class WebSession {
return;
}
var form_data = Soup.Form.decode((string) msg.request_body.data);
- if (form_data == null || !form_data.contains("user") || !form_data.contains("password")) {
- return;
- }
+ if (form_data == null || !form_data.contains("user") || !form_data.contains("password")) {
+ return;
+ }
/* get credentials */
@@ -162,7 +162,7 @@ public class WebSession {
setup_auth(user);
} else {
- stderr.printf("Login for user id %d failed\n", userid);
+ stderr.printf(_("Login for user id %d failed\n"), userid);
/* login failed */
failed=true;
}