7
7
extern const string _VERSION;
9
namespace Publishing.Extras {
11
internal const string DOMAIN_NAME = "shotwell-extras";
12
internal const string[] LANGUAGE_SUPPORT_DIRECTORIES = {
14
"/usr/local/share/locale-langpack",
15
"/usr/share/locale-langpack",
16
"/usr/local/share/locale",
17
"/usr/local/share/locale-langpack"
20
internal bool is_domain_configured = false;
22
public void configure_translation_domain() {
23
if (is_domain_configured)
26
string target = DOMAIN_NAME + ".mo";
28
// support installation of the shotwell-extras translations separately from the shotwell core
29
// translations; look for shotwell-extras translations in all 5 common locations.
30
string? lang_support_dir = null;
31
foreach (string dirpath in LANGUAGE_SUPPORT_DIRECTORIES) {
32
File base_dirfile = File.new_for_path(dirpath);
33
if (!base_dirfile.query_exists(null))
36
FileType base_filetype =
37
base_dirfile.query_file_type(FileQueryInfoFlags.NONE, null);
38
if (base_filetype != FileType.DIRECTORY)
42
FileEnumerator lang_enumerator =
43
base_dirfile.enumerate_children("standard::name,standard::type",
44
FileQueryInfoFlags.NONE, null);
46
while ((info = lang_enumerator.next_file(null)) != null) {
47
if (info.get_file_type() == FileType.DIRECTORY) {
48
File message_domain_file = base_dirfile.get_child(info.get_name()).get_child(
49
"LC_MESSAGES").get_child(target);
51
if (message_domain_file.query_exists(null)) {
52
lang_support_dir = base_dirfile.get_path();
58
critical("can't get location of translation file for extra plugins: " + e.message);
61
if (lang_support_dir != null)
65
if (lang_support_dir != null) {
66
string? bound = Intl.bindtextdomain(DOMAIN_NAME, lang_support_dir);
69
debug("bound shotwell-extras language support directory '%s'.\n", lang_support_dir);
72
is_domain_configured = true;
75
public unowned string? _t(string msgid) {
76
if (!is_domain_configured)
77
configure_translation_domain();
79
return dgettext(DOMAIN_NAME, msgid);
82
public unowned string? _tn(string msgid, string msgid_plural, ulong n) {
83
if (!is_domain_configured)
84
configure_translation_domain();
86
return dngettext(DOMAIN_NAME, msgid, msgid_plural, n);
90
9
private class ShotwellPublishingExtraServices : Object, Spit.Module {
91
10
private Spit.Pluggable[] pluggables = new Spit.Pluggable[0];