diff options
Diffstat (limited to 'src/web')
-rw-r--r-- | src/web/Makefile | 2 | ||||
-rw-r--r-- | src/web/main.vala | 21 | ||||
-rw-r--r-- | src/web/template.vala | 24 | ||||
-rw-r--r-- | src/web/web.vala | 4 | ||||
-rw-r--r-- | src/web/websession.vala | 8 |
5 files changed, 31 insertions, 28 deletions
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; } |