Merge lp:~tintou/slingshot/translate-actions into lp:~elementary-pantheon/slingshot/trunk

Proposed by Corentin Noël on 2015-12-23
Status: Merged
Approved by: Cody Garver on 2016-02-10
Approved revision: 618
Merged at revision: 630
Proposed branch: lp:~tintou/slingshot/translate-actions
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 101 lines (+31/-1)
2 files modified
lib/synapse-core/desktop-file-service.vala (+8/-0)
lib/synapse-plugins/desktop-file-plugin.vala (+23/-1)
To merge this branch: bzr merge lp:~tintou/slingshot/translate-actions
Reviewer Review Type Date Requested Status
elementary Pantheon team 2015-12-23 Pending
Review via email: mp+281304@code.launchpad.net

Commit message

Translate applications actions

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/synapse-core/desktop-file-service.vala'
2--- lib/synapse-core/desktop-file-service.vala 2014-08-21 14:08:17 +0000
3+++ lib/synapse-core/desktop-file-service.vala 2015-12-23 15:11:31 +0000
4@@ -53,6 +53,7 @@
5 public string generic_name { get; construct set; }
6 public string comment { get; set; default = ""; }
7 public string icon_name { get; construct set; default = ""; }
8+ public string gettext_domain { get; construct set; }
9
10 public bool needs_terminal { get; set; default = false; }
11 public string filename { get; construct set; }
12@@ -73,6 +74,7 @@
13
14 public EnvironmentType show_in { get; set; default = EnvironmentType.ALL; }
15
16+ private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"};
17 private static const string GROUP = "Desktop Entry";
18
19 public DesktopFileInfo.for_keyfile (string path, KeyFile keyfile,
20@@ -125,6 +127,12 @@
21 throw new DesktopFileError.UNINTERESTING_ENTRY ("Screensaver desktop entry");
22 }
23 }
24+ foreach (var domain_key in SUPPORTED_GETTEXT_DOMAINS_KEYS) {
25+ if (keyfile.has_key (GROUP, domain_key)) {
26+ gettext_domain = keyfile.get_string (GROUP, domain_key);
27+ break;
28+ }
29+ }
30
31 DesktopAppInfo app_info;
32 app_info = new DesktopAppInfo.from_keyfile (keyfile);
33
34=== modified file 'lib/synapse-plugins/desktop-file-plugin.vala'
35--- lib/synapse-plugins/desktop-file-plugin.vala 2015-09-20 17:50:48 +0000
36+++ lib/synapse-plugins/desktop-file-plugin.vala 2015-12-23 15:11:31 +0000
37@@ -48,12 +48,25 @@
38 public AppInfo? app_info { get; set; default = null; }
39 public bool needs_terminal { get; set; default = false; }
40
41+ private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"};
42 private string action_name;
43
44 public ActionMatch (string desktop_id, string action_name)
45 {
46 var desktop_app_info = new DesktopAppInfo (desktop_id);
47+ string? textdomain = null;
48+ foreach (var domain_key in SUPPORTED_GETTEXT_DOMAINS_KEYS) {
49+ textdomain = desktop_app_info.get_string (domain_key);
50+ if (textdomain != null) {
51+ break;
52+ }
53+ }
54+
55 this.title = desktop_app_info.get_action_name (action_name);
56+ if (textdomain != null) {
57+ this.title = GLib.dgettext (textdomain, this.title);
58+ }
59+
60 this.icon_name = desktop_app_info.get_icon ().to_string ();
61 this.description = "";
62 this.app_info = desktop_app_info;
63@@ -71,6 +84,7 @@
64 // for Match interface
65 public string title { get; construct set; }
66 public string description { get; set; default = ""; }
67+ public string? gettext_domain { get; construct set; default = null; }
68 public string icon_name { get; construct set; default = ""; }
69 public bool has_thumbnail { get; construct set; default = false; }
70 public string thumbnail_path { get; construct set; }
71@@ -114,6 +128,7 @@
72 this.title_unaccented = Utils.remove_accents (this.title_folded);
73 this.desktop_id = "application://" + info.desktop_id;
74 this.generic_name = info.generic_name;
75+ this.gettext_domain = info.gettext_domain;
76 }
77 }
78
79@@ -197,6 +212,7 @@
80 unowned string unaccented_title = dfm.title_unaccented;
81 unowned string comment = dfm.description;
82 unowned string generic_name = dfm.generic_name;
83+ unowned string gettext_domain = dfm.gettext_domain;
84
85 bool matched = false;
86 // FIXME: we need to do much smarter relevancy computation in fuzzy re
87@@ -229,7 +245,13 @@
88 var desktop_app_info = new DesktopAppInfo (id);
89 string[] actions = desktop_app_info.list_actions ();
90 foreach (string action in actions) {
91- string title = desktop_app_info.get_action_name (action).down ();
92+ string title = desktop_app_info.get_action_name (action);
93+ if (gettext_domain != null) {
94+ title = GLib.dgettext (gettext_domain, title).down ();
95+ } else {
96+ title = title.down ();
97+ }
98+
99 foreach (var matcher in matchers)
100 {
101 MatchInfo action_info;

Subscribers

People subscribed via source and target branches