Skip to content

Commit 693c535

Browse files
committed
Improving with feedback from @supertobi
1 parent 1785285 commit 693c535

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

contrib/fujifilm_ratings.lua

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,48 @@ Dependencies:
2323
2424
--]]
2525

26-
darktable = require "darktable"
26+
local dt = require "darktable"
27+
local df = require "lib/dtutils.file"
28+
local gettext = dt.gettext
29+
30+
dt.configuration.check_version(..., {4,0,0})
31+
32+
gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/")
33+
34+
local function _(msgid)
35+
return gettext.dgettext("fujifilm_ratings", msgid)
36+
end
2737

2838
local function detect_rating(event, image)
39+
if not df.check_if_bin_exists("exiftool") then
40+
dt.print_error(_("exiftool not found"))
41+
return
42+
end
2943
local RAF_filename = tostring(image)
3044
local JPEG_filename = string.gsub(RAF_filename, "%.RAF$", ".JPG")
3145
local command = "exiftool -Rating " .. JPEG_filename
32-
darktable.print_error(command)
46+
dt.print_error(command)
3347
local output = io.popen(command)
3448
local jpeg_result = output:read("*all")
3549
output:close()
3650
if string.len(jpeg_result) > 0 then
3751
jpeg_result = string.gsub(jpeg_result, "^Rating.*(%d)", "%1")
3852
image.rating = tonumber(jpeg_result)
39-
darktable.print_error("Using JPEG Rating: " .. tostring(jpeg_result))
53+
dt.print_error(_("Using JPEG Rating: ") .. tostring(jpeg_result))
4054
return
4155
end
4256
command = "exiftool -Rating " .. RAF_filename
43-
darktable.print_error(command)
57+
dt.print_error(command)
4458
output = io.popen(command)
4559
local raf_result = output:read("*all")
4660
output:close()
4761
if string.len(raf_result) > 0 then
4862
raf_result = string.gsub(raf_result, "^Rating.*(%d)", "%1")
4963
image.rating = tonumber(raf_result)
50-
darktable.print_error("Using RAF Rating: " .. tostring(raf_result))
64+
dt.print_error(_("Using RAF Rating: ") .. tostring(raf_result))
5165
end
5266
end
5367

54-
darktable.register_event("post-import-image", detect_rating)
68+
dt.register_event("post-import-image", detect_rating)
5569

56-
darktable.print_error("fujifilm_ratings loaded.")
70+
print(_("fujifilm_ratings loaded."))

0 commit comments

Comments
 (0)