17
17
]]
18
18
19
19
--[[ About this Plugin
20
- This plugin adds the module " HDRMerge" to darktable's lighttable view
20
+ This plugin adds the module ' HDRMerge' to darktable's lighttable view
21
21
22
22
----REQUIRED SOFTWARE----
23
23
HDRMerge ver. 4.5 or greater
24
24
25
25
----USAGE----
26
26
Install: (see here for more detail: https://github.com/darktable-org/lua-scripts )
27
- 1) Copy this file in to your " lua/contrib" folder where all other scripts reside.
27
+ 1) Copy this file in to your ' lua/contrib' folder where all other scripts reside.
28
28
2) Require this file in your luarc file, as with any other dt plug-in
29
29
On the initial startup go to darktable settings > lua options and set your executable paths and other preferences, then restart darktable
30
30
@@ -44,13 +44,20 @@ Auto-import Options:
44
44
Select a style, whether you want tags to be copied from the original, and any additional tags you desire added when the new image is auto-imported
45
45
]]
46
46
47
- local dt = require " darktable"
48
- local df = require " lib/dtutils.file"
49
- local dsys = require " lib/dtutils.system"
47
+ local dt = require ' darktable'
48
+ local df = require ' lib/dtutils.file'
49
+ local dsys = require ' lib/dtutils.system'
50
50
local mod = ' module_HDRMerge'
51
51
local os_path_seperator = ' /'
52
52
if dt .configuration .running_os == ' windows' then os_path_seperator = ' \\ ' end
53
53
54
+ -- Tell gettext where to find the .mo file translating messages for a particular domain
55
+ local gettext = dt .gettext
56
+ gettext .bindtextdomain (' HDRMerge' ,dt .configuration .config_dir .. ' /lua/locale/' )
57
+ local function _ (msgid )
58
+ return gettext .dgettext (' HDRMerge' , msgid )
59
+ end
60
+
54
61
local temp
55
62
local HDRM = { -- HDRMerge Program Table
56
63
name = ' HDRMerge' ,
@@ -89,9 +96,9 @@ local GUI = { --GUI Elements Table
89
96
90
97
-- Detect User Styles--
91
98
local styles = dt .styles
92
- local styles_count = 1 -- " none" = 1
99
+ local styles_count = 1 -- ' none' = 1
93
100
for _ ,i in pairs (dt .styles ) do
94
- if type (i ) == " userdata" then styles_count = styles_count + 1 end
101
+ if type (i ) == ' userdata' then styles_count = styles_count + 1 end
95
102
end
96
103
97
104
local function InRange (test , low , high ) -- tests if test value is within range of low and high (inclusive)
@@ -114,10 +121,10 @@ local function GetFileName(full_path) --Parses a full path (path/filename_identi
114
121
EX:
115
122
path_1, file_1, id_1, ext_1 = GetFileName(full_path_1)
116
123
]]
117
- local path = string.match (full_path , " .*[\\ /]" )
118
- local filename = string.gsub (string.match (full_path , " [%w-_]*%." ) , " %. " , " " )
119
- local identifier = string.match (filename , " %d*$" )
120
- local extension = string.match (full_path , " %.%w*" )
124
+ local path = string.match (full_path , ' .*[\\ /]' )
125
+ local filename = string.gsub (string.match (full_path , ' [%w-_]*%.' ) , ' %. ' , ' ' )
126
+ local identifier = string.match (filename , ' %d*$' )
127
+ local extension = string.match (full_path , ' %.%w*' )
121
128
return path , filename , identifier , extension
122
129
end
123
130
@@ -147,7 +154,7 @@ local function PreCall(prog_tbl) --looks to see if this is the first call, if so
147
154
end
148
155
if not dt .preferences .read (mod , ' bin_exists' , ' bool' ) then
149
156
GUI .stack .active = 2
150
- dt .print (' please update you binary locatoin' )
157
+ dt .print (_ ( ' please update you binary locatoin' ) )
151
158
end
152
159
end
153
160
@@ -166,9 +173,9 @@ local function ExeUpdate(prog_tbl)
166
173
end
167
174
if dt .preferences .read (mod , ' bin_exists' , ' bool' ) then
168
175
GUI .stack .active = 1
169
- dt .print (' update successful' )
176
+ dt .print (_ ( ' update successful' ) )
170
177
else
171
- dt .print (' update unsuccessful, please try again' )
178
+ dt .print (_ ( ' update unsuccessful, please try again' ) )
172
179
end
173
180
end
174
181
@@ -182,13 +189,13 @@ end
182
189
local function main ()
183
190
PreCall ({HDRM }) -- check if furst run then check if install OK
184
191
if HDRM .install_error then
185
- dt .print_error (' HDRMerge install issue' )
186
- dt .print (' HDRMerge install issue, please ensure the binary path is proper' )
192
+ dt .print_error (_ ( ' HDRMerge install issue' ) )
193
+ dt .print (_ ( ' HDRMerge install issue, please ensure the binary path is proper' ) )
187
194
return
188
195
end
189
196
images = dt .gui .selection () -- get selected images
190
197
if # images < 2 then -- ensure enough images selected
191
- dt .print (' not enough images selected, select at least 2 images to merge' )
198
+ dt .print (_ ( ' not enough images selected, select at least 2 images to merge' ) )
192
199
return
193
200
end
194
201
@@ -203,7 +210,7 @@ local function main()
203
210
local source_raw = {}
204
211
for _ ,image in pairs (images ) do -- loop to concat the images string, also track the image indexes for use in creating the final image name (eg; IMG_1034-1037.dng)
205
212
local curr_image = image .path .. os_path_seperator .. image .filename
206
- HDRM .images_string = HDRM .images_string .. df .sanitize_filename (curr_image ).. " "
213
+ HDRM .images_string = HDRM .images_string .. df .sanitize_filename (curr_image ).. ' '
207
214
out_path = image .path
208
215
_ , source_name , source_id = GetFileName (image .filename )
209
216
source_id = tonumber (source_id )
@@ -249,23 +256,23 @@ local function main()
249
256
dt .tags .attach (tag , imported )
250
257
end
251
258
end
252
- dt .print (' HDRMerge completed successfully' )
259
+ dt .print (_ ( ' HDRMerge completed successfully' ) )
253
260
else
254
- dt .print_error (' HDRMerge failed' )
255
- dt .print (' HDRMerge failed' )
261
+ dt .print_error (_ ( ' HDRMerge failed' ) )
262
+ dt .print (_ ( ' HDRMerge failed' ) )
256
263
end
257
264
258
265
end
259
266
260
267
-- GUI Elements --
261
268
local lbl_hdr = dt .new_widget (' section_label' ){
262
- label = ' HDRMerge options'
269
+ label = _ ( ' HDRMerge options' )
263
270
}
264
271
temp = dt .preferences .read (mod , ' active_bps_ind' , ' integer' )
265
272
if not InRange (temp , 1 , 3 ) then temp = 3 end
266
273
GUI .HDR .bps = dt .new_widget (' combobox' ){
267
- label = ' bits per sample' ,
268
- tooltip = ' number of bits per sample in the output image' ,
274
+ label = _ ( ' bits per sample' ) ,
275
+ tooltip = _ ( ' number of bits per sample in the output image' ) ,
269
276
selected = temp ,
270
277
' 16' ,' 24' ,' 32' ,
271
278
changed_callback = function (self )
@@ -281,10 +288,10 @@ GUI.HDR.bps = dt.new_widget('combobox'){
281
288
temp = dt .preferences .read (mod , ' active_size_ind' , ' integer' )
282
289
if not InRange (temp , 1 , 3 ) then temp = 2 end
283
290
GUI .HDR .size = dt .new_widget (' combobox' ){
284
- label = ' embedded preview size' ,
285
- tooltip = ' size of the embedded preview in output image' ,
291
+ label = _ ( ' embedded preview size' ) ,
292
+ tooltip = _ ( ' size of the embedded preview in output image' ) ,
286
293
selected = temp ,
287
- ' none' , ' half' , ' full' ,
294
+ _ ( ' none' ), _ ( ' half' ), _ ( ' full' ) ,
288
295
changed_callback = function (self )
289
296
dt .preferences .write (mod , ' active_size' , ' string' , self .value )
290
297
dt .preferences .write (mod , ' active_size_ind' , ' integer' , self .selected )
@@ -296,9 +303,9 @@ GUI.HDR.size = dt.new_widget('combobox'){
296
303
end
297
304
}
298
305
GUI .HDR .batch = dt .new_widget (' check_button' ){
299
- label = ' batch mode' ,
306
+ label = _ ( ' batch mode' ) ,
300
307
value = dt .preferences .read (mod , ' active_batch' , ' bool' ),
301
- tooltip = ' enable batch mode operation \n NOTE: resultant files will NOT be auto-imported' ,
308
+ tooltip = _ ( ' enable batch mode operation \n NOTE: resultant files will NOT be auto-imported' ) ,
302
309
clicked_callback = function (self )
303
310
dt .preferences .write (mod , ' active_batch' , ' bool' , self .value )
304
311
GUI .HDR .gap .sensitive = self .value
@@ -308,8 +315,8 @@ GUI.HDR.batch = dt.new_widget('check_button'){
308
315
temp = dt .preferences .read (mod , ' active_gap' , ' integer' )
309
316
if not InRange (temp , 1 , 3600 ) then temp = 3 end
310
317
GUI .HDR .gap = dt .new_widget (' slider' ){
311
- label = ' batch gap [sec.]' ,
312
- tooltip = ' gap, in seconds, between batch mode groups' ,
318
+ label = _ ( ' batch gap [sec.]' ) ,
319
+ tooltip = _ ( ' gap, in seconds, between batch mode groups' ) ,
313
320
soft_min = 1 ,
314
321
soft_max = 30 ,
315
322
hard_min = 1 ,
@@ -323,13 +330,13 @@ GUI.HDR.gap = dt.new_widget('slider'){
323
330
end
324
331
}
325
332
local lbl_import = dt .new_widget (' section_label' ){
326
- label = ' import options'
333
+ label = _ ( ' import options' )
327
334
}
328
335
GUI .Target .style = dt .new_widget (' combobox' ){
329
- label = ' apply style on import' ,
330
- tooltip = " Apply selected style on auto-import to newly created image" ,
336
+ label = _ ( ' apply style on import' ) ,
337
+ tooltip = _ ( ' Apply selected style on auto-import to newly created image' ) ,
331
338
selected = 1 ,
332
- " none" ,
339
+ _ ( ' none' ) ,
333
340
changed_callback = function (self )
334
341
dt .preferences .write (mod , ' active_style' , ' string' , self .value )
335
342
dt .preferences .write (mod , ' active_style_ind' , ' integer' , self .selected )
@@ -347,33 +354,33 @@ temp = dt.preferences.read(mod, 'active_style_ind', 'integer')
347
354
if not InRange (temp , 1 , styles_count ) then temp = 1 end
348
355
GUI .Target .style .selected = temp
349
356
GUI .Target .copy_tags = dt .new_widget (' check_button' ){
350
- label = ' copy tags' ,
357
+ label = _ ( ' copy tags' ) ,
351
358
value = dt .preferences .read (mod , ' active_copy_tags' , ' bool' ),
352
- tooltip = ' copy tags from first source image' ,
359
+ tooltip = _ ( ' copy tags from first source image' ) ,
353
360
clicked_callback = function (self ) dt .preferences .write (mod , ' active_copy_tags' , ' bool' , self .value ) end ,
354
361
reset_callback = function (self ) self .value = true end
355
362
}
356
363
temp = dt .preferences .read (mod , ' active_add_tags' , ' string' )
357
364
if temp == ' ' then temp = nil end
358
- GUI .Target .add_tags = dt .new_widget (" entry" ){
359
- tooltip = " Additional tags to be added on import. Seperate with commas, all spaces will be removed" ,
365
+ GUI .Target .add_tags = dt .new_widget (' entry' ){
366
+ tooltip = _ ( ' Additional tags to be added on import. Seperate with commas, all spaces will be removed' ) ,
360
367
text = temp ,
361
- placeholder = " Enter tags, seperated by commas" ,
368
+ placeholder = _ ( ' Enter tags, seperated by commas' ) ,
362
369
editable = true
363
370
}
364
- GUI .run = dt .new_widget (" button" ){
365
- label = ' merge' ,
366
- tooltip = ' run HDRMerge with the above specified settings' ,
371
+ GUI .run = dt .new_widget (' button' ){
372
+ label = _ ( ' merge' ) ,
373
+ tooltip = _ ( ' run HDRMerge with the above specified settings' ) ,
367
374
clicked_callback = function () main () end
368
375
}
369
376
GUI .exes .HDRMerge = dt .new_widget (' file_chooser_button' ){
370
- title = " Select HDRmerge executable" ,
377
+ title = _ ( ' Select HDRmerge executable' ) ,
371
378
value = df .get_executable_path_preference (HDRM .name ),
372
379
is_directory = false
373
380
}
374
381
GUI .exes .update = dt .new_widget (' button' ){
375
- label = ' update' ,
376
- tooltip = ' update the binary path with current value' ,
382
+ label = _ ( ' update' ) ,
383
+ tooltip = _ ( ' update the binary path with current value' ) ,
377
384
clicked_callback = function () ExeUpdate ({HDRM }) end
378
385
}
379
386
GUI .options = dt .new_widget (' box' ){
@@ -399,19 +406,19 @@ GUI.stack = dt.new_widget('stack'){
399
406
exes_box
400
407
}
401
408
if dt .preferences .read (mod , ' bin_exists' , ' bool' ) then
402
- GUI .stack .active = 1
409
+ GUI .stack .active = 1
403
410
else
404
411
GUI .stack .active = 2
405
412
end
406
413
407
414
dt .register_lib ( -- register HDRMerge module
408
- " HDRMerge_Lib" , -- Module name
409
- " HDRMerge" , -- name
415
+ ' HDRMerge_Lib' , -- Module name
416
+ _ ( ' HDRMerge' ) , -- name
410
417
true , -- expandable
411
418
true , -- resetable
412
- {[dt .gui .views .lighttable ] = {" DT_UI_CONTAINER_PANEL_RIGHT_CENTER" , 99 }}, -- containers
413
- dt .new_widget (" box" ){
414
- orientation = " vertical" ,
419
+ {[dt .gui .views .lighttable ] = {' DT_UI_CONTAINER_PANEL_RIGHT_CENTER' , 99 }}, -- containers
420
+ dt .new_widget (' box' ){
421
+ orientation = ' vertical' ,
415
422
GUI .stack
416
423
}
417
424
)
0 commit comments