blob: 555a91f8ccf448ee70bd25407dd731d3534588ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/* Copyright 2016 Software Freedom Conservancy Inc.
*
* 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_parent().get_child(
"locale-langpack");
return (local_langpack_dir.query_exists(null)) ? local_langpack_dir.get_path() :
LANGUAGE_SUPPORT_DIRECTORY;
}
}
|