diff options
author | Sebastian Reichel <sre@ring0.de> | 2018-06-28 21:35:23 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2018-06-28 23:15:27 +0200 |
commit | ea64727f90a5f9a66c2fa81612e46ecdae438303 (patch) | |
tree | 87d51301d0124e3a01fc434413b38a63ecdd31ef /src/web/main.vala | |
parent | fb75ceb1c5a415cc6667043b1123e42586b1d9b1 (diff) | |
download | serial-barcode-scanner-testing.tar.bz2 |
all: I18N supporttesting
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, "");
Diffstat (limited to 'src/web/main.vala')
-rw-r--r-- | src/web/main.vala | 21 |
1 files changed, 12 insertions, 9 deletions
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 */ |