@@ -46,17 +46,36 @@ In the "Selected Images" module click on "Collect on this Image"
46
46
]]
47
47
48
48
local dt = require " darktable"
49
+ local gettext = dt .gettext
49
50
local previous = nil
50
51
local all_active = false
51
52
53
+ -- Tell gettext where to find the .mo file translating messages for a particular domain
54
+ gettext .bindtextdomain (" gimp" ,dt .configuration .config_dir .. " /lua/locale/" )
55
+
56
+ local function _ (msgid )
57
+ return gettext .dgettext (" CollectHelper" , msgid )
58
+ end
59
+
52
60
-- FUNCTION --
53
61
local function CheckSingleImage (selection )
54
62
if # selection ~= 1 then
55
- dt .print (" Please select a single image" )
63
+ dt .print (_ ( " Please select a single image" ) )
56
64
return true
57
65
end
58
66
return false
59
67
end
68
+ local function CheckHasColorLabel (selection )
69
+ local ret = false
70
+ for _ ,image in pairs (selection ) do
71
+ if image .red then ret = true end
72
+ if image .blue then ret = true end
73
+ if image .green then ret = true end
74
+ if image .yellow then ret = true end
75
+ if image .purple then ret = true end
76
+ end
77
+ return ret
78
+ end
60
79
local function PreviousCollection ()
61
80
if previous ~= nil then
62
81
previous = dt .gui .libs .collect .filter (previous )
@@ -87,6 +106,10 @@ local function CollectOnColors(all_rules, all_active)
87
106
if CheckSingleImage (images ) then
88
107
return
89
108
end
109
+ if not CheckHasColorLabel (images ) then
110
+ dt .print (_ (' select an image with an active color label' ))
111
+ return
112
+ end
90
113
for _ ,image in pairs (images ) do
91
114
local rules = {}
92
115
if image .red then
@@ -151,48 +174,48 @@ end
151
174
152
175
-- GUI --
153
176
dt .gui .libs .image .register_action (
154
- " collect: previous" ,
177
+ _ ( " collect: previous" ) ,
155
178
function () PreviousCollection () end ,
156
- " Sets the Collect parameters to be the previously active parameters"
179
+ _ ( " Sets the Collect parameters to be the previously active parameters" )
157
180
)
158
181
if dt .preferences .read (' module_CollectHelper' ,' folder' ,' bool' ) then
159
182
dt .gui .libs .image .register_action (
160
- " collect: folder" ,
183
+ _ ( " collect: folder" ) ,
161
184
function () CollectOnFolder (_ , false ) end ,
162
- " Sets the Collect parameters to be the selected images's folder"
185
+ _ ( " Sets the Collect parameters to be the selected images's folder" )
163
186
)
164
187
end
165
188
if dt .preferences .read (' module_CollectHelper' ,' colors' ,' bool' ) then
166
189
dt .gui .libs .image .register_action (
167
- " collect: color label(s)" ,
190
+ _ ( " collect: color label(s)" ) ,
168
191
function () CollectOnColors (_ , false ) end ,
169
- " Sets the Collect parameters to be the selected images's color label(s)"
192
+ _ ( " Sets the Collect parameters to be the selected images's color label(s)" )
170
193
)
171
194
end
172
195
if dt .preferences .read (' module_CollectHelper' ,' all_and' ,' bool' ) then
173
196
dt .gui .libs .image .register_action (
174
- " collect: all (AND)" ,
197
+ _ ( " collect: all (AND)" ) ,
175
198
function () CollectOnAll_AND () end ,
176
- " Sets the Collect parameters based on all activated CollectHelper options"
199
+ _ ( " Sets the Collect parameters based on all activated CollectHelper options" )
177
200
)
178
201
end
179
202
180
203
-- PREFERENCES --
181
204
dt .preferences .register (" module_CollectHelper" , " all_and" , -- name
182
205
" bool" , -- type
183
- ' CollectHelper: All' , -- label
184
- ' Will create a collect parameter set that utelizes all enabled CollectHelper types (AND)' , -- tooltip
206
+ _ ( ' CollectHelper: All' ) , -- label
207
+ _ ( ' Will create a collect parameter set that utelizes all enabled CollectHelper types (AND)' ) , -- tooltip
185
208
true -- default
186
209
)
187
210
dt .preferences .register (" module_CollectHelper" , " colors" , -- name
188
211
" bool" , -- type
189
- ' CollectHelper: Color Label(s)' , -- label
190
- ' Enable the button that allows you to swap to a collection based on selected image\' s COLOR LABEL(S)' , -- tooltip
212
+ _ ( ' CollectHelper: Color Label(s)' ) , -- label
213
+ _ ( ' Enable the button that allows you to swap to a collection based on selected image\' s COLOR LABEL(S)' ) , -- tooltip
191
214
true -- default
192
215
)
193
216
dt .preferences .register (" module_CollectHelper" , " folder" , -- name
194
217
" bool" , -- type
195
- ' CollectHelper: Folder' , -- label
196
- ' Enable the button that allows you to swap to a collection based on selected image\' s FOLDER location' , -- tooltip
218
+ _ ( ' CollectHelper: Folder' ) , -- label
219
+ _ ( ' Enable the button that allows you to swap to a collection based on selected image\' s FOLDER location' ) , -- tooltip
197
220
true -- default
198
221
)
0 commit comments