diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 09:06:59 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 09:06:59 +0200 |
commit | 4ea2cc3bd4a7d9b1c54a9d33e6a1cf82e7c8c21d (patch) | |
tree | d2e54377d14d604356c86862a326f64ae64dadd6 /src/International.vala |
Imported Upstream version 0.18.1upstream/0.18.1
Diffstat (limited to 'src/International.vala')
-rw-r--r-- | src/International.vala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/International.vala b/src/International.vala new file mode 100644 index 0000000..1bf242b --- /dev/null +++ b/src/International.vala @@ -0,0 +1,32 @@ +/* Copyright 2009-2014 Yorba Foundation + * + * This software is licensed under the GNU LGPL (version 2.1 or later). + * See the COPYING file in this distribution. + */ + +extern const string _LANG_SUPPORT_DIR; + +public const string TRANSLATABLE = "translatable"; + +namespace InternationalSupport { +const string SYSTEM_LOCALE = ""; +const string LANGUAGE_SUPPORT_DIRECTORY = _LANG_SUPPORT_DIR; + +void init(string package_name, string[] args, string locale = SYSTEM_LOCALE) { + Intl.setlocale(LocaleCategory.ALL, locale); + + Intl.bindtextdomain(package_name, get_langpack_dir_path(args)); + Intl.bind_textdomain_codeset(package_name, "UTF-8"); + Intl.textdomain(package_name); +} + +private string get_langpack_dir_path(string[] args) { + File local_langpack_dir = + File.new_for_path(Environment.find_program_in_path(args[0])).get_parent().get_child( + "locale-langpack"); + + return (local_langpack_dir.query_exists(null)) ? local_langpack_dir.get_path() : + LANGUAGE_SUPPORT_DIRECTORY; +} +} + |