~tristang4/pantheon-photos/update-icons

« back to all changes in this revision

Viewing changes to plugins/shotwell-publishing-extras/shotwell-publishing-extras.vala

  • Committer: Charles Lindsay
  • Date: 2014-01-15 19:51:09 UTC
  • Revision ID: git-v1:e9f5eefa7ddcf74406e5686c27442f1111b952af
Merge po files, set up for intltool and l10n.gnome.org

This removes the custom .pot file setup we had before, making it easy to
translate Shotwell using the standard intltool workflow.

This also merges the two separate core/extras gettext domains into one,
to keep things simple.  I hope I've merged all the po files correctly,
but I wouldn't bet money I did it perfectly.

We also set up the help to be able to be translated on l10n.gnome.org.

Closes: bgo #718783

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
extern const string _VERSION;
8
8
 
9
 
namespace Publishing.Extras {
10
 
 
11
 
internal const string DOMAIN_NAME = "shotwell-extras";
12
 
internal const string[] LANGUAGE_SUPPORT_DIRECTORIES = {
13
 
    "./locale-langpack",
14
 
    "/usr/local/share/locale-langpack",
15
 
    "/usr/share/locale-langpack",
16
 
    "/usr/local/share/locale",
17
 
    "/usr/local/share/locale-langpack"
18
 
};
19
 
 
20
 
internal bool is_domain_configured = false;
21
 
 
22
 
public void configure_translation_domain() {
23
 
    if (is_domain_configured)
24
 
        return;
25
 
 
26
 
    string target = DOMAIN_NAME + ".mo";
27
 
 
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))
34
 
            continue;
35
 
 
36
 
        FileType base_filetype =
37
 
            base_dirfile.query_file_type(FileQueryInfoFlags.NONE, null);
38
 
        if (base_filetype != FileType.DIRECTORY)
39
 
            continue;
40
 
        
41
 
        try {
42
 
            FileEnumerator lang_enumerator =
43
 
                base_dirfile.enumerate_children("standard::name,standard::type",
44
 
                FileQueryInfoFlags.NONE, null);
45
 
            FileInfo info = 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);
50
 
 
51
 
                    if (message_domain_file.query_exists(null)) {
52
 
                        lang_support_dir = base_dirfile.get_path();
53
 
                        break;
54
 
                    }
55
 
                }
56
 
            }
57
 
        } catch (Error e) {
58
 
            critical("can't get location of translation file for extra plugins: " + e.message);
59
 
        }
60
 
        
61
 
        if (lang_support_dir != null)
62
 
            break;
63
 
     }
64
 
 
65
 
    if (lang_support_dir != null) {
66
 
        string? bound = Intl.bindtextdomain(DOMAIN_NAME, lang_support_dir);
67
 
        
68
 
        if (bound != null)
69
 
            debug("bound shotwell-extras language support directory '%s'.\n", lang_support_dir);
70
 
    }
71
 
 
72
 
    is_domain_configured = true;
73
 
}
74
 
 
75
 
public unowned string? _t(string msgid) {
76
 
    if (!is_domain_configured)
77
 
        configure_translation_domain();
78
 
 
79
 
    return dgettext(DOMAIN_NAME, msgid);
80
 
}
81
 
 
82
 
public unowned string? _tn(string msgid, string msgid_plural, ulong n) {
83
 
    if (!is_domain_configured)
84
 
        configure_translation_domain();
85
 
    
86
 
    return dngettext(DOMAIN_NAME, msgid, msgid_plural, n);
87
 
}
88
 
}
89
 
 
90
9
private class ShotwellPublishingExtraServices : Object, Spit.Module {
91
10
    private Spit.Pluggable[] pluggables = new Spit.Pluggable[0];
92
11
 
117
36
    params->module_spit_interface = Spit.negotiate_interfaces(params->host_min_spit_interface,
118
37
        params->host_max_spit_interface, Spit.CURRENT_INTERFACE);
119
38
    
120
 
    Publishing.Extras.configure_translation_domain();
121
 
    
122
39
    return (params->module_spit_interface != Spit.UNSUPPORTED_INTERFACE)
123
40
        ? new ShotwellPublishingExtraServices(params->module_file) : null;
124
41
}