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/pgp | |
parent | fb75ceb1c5a415cc6667043b1123e42586b1d9b1 (diff) | |
download | serial-barcode-scanner-ea64727f90a5f9a66c2fa81612e46ecdae438303.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/pgp')
-rw-r--r-- | src/pgp/Makefile | 2 | ||||
-rw-r--r-- | src/pgp/main.vala | 18 | ||||
-rw-r--r-- | src/pgp/pgp.vala | 2 |
3 files changed, 12 insertions, 10 deletions
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 ""; } } |