updated official scripts to use darktable translation facilities
This commit is contained in:
@@ -27,7 +27,7 @@ USAGE
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
local gettext = dt.gettext
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
du.check_min_api_version("7.0.0", "copy_paste_metadata")
|
||||
|
||||
@@ -58,11 +58,8 @@ local publisher = ""
|
||||
local rights = ""
|
||||
local tags = {}
|
||||
|
||||
-- Tell gettext where to find the .mo file translating messages for a particular domain
|
||||
gettext.bindtextdomain("copy_paste_metadata",dt.configuration.config_dir.."/lua/locale/")
|
||||
|
||||
local function _(msgid)
|
||||
return gettext.dgettext("copy_paste_metadata", msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
local function copy(image)
|
||||
@@ -147,13 +144,13 @@ dt.gui.libs.image.register_action(
|
||||
dt.register_event(
|
||||
"capmd1", "shortcut",
|
||||
function(event, shortcut) copy(dt.gui.action_images[1]) end,
|
||||
"copy metadata"
|
||||
_("copy metadata")
|
||||
)
|
||||
|
||||
dt.register_event(
|
||||
"capmd2", "shortcut",
|
||||
function(event, shortcut) paste(dt.gui.action_images) end,
|
||||
"paste metadata"
|
||||
_("paste metadata")
|
||||
)
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
@@ -59,7 +59,7 @@ local long_tags = {}
|
||||
for _,t in ipairs(dt.tags) do
|
||||
local len = #t.name
|
||||
if len > max_length then
|
||||
print("deleting tag `"..t.name.."' (length: "..len..")")
|
||||
dt.print_log("deleting tag `"..t.name.."' (length: "..len..")")
|
||||
table.insert(long_tags, t.name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,7 +56,7 @@ for _, t in ipairs(dt.tags) do
|
||||
end
|
||||
|
||||
for _,name in pairs(unused_tags) do
|
||||
print("deleting tag `" .. name .. "'")
|
||||
dt.print_log("deleting tag `" .. name .. "'")
|
||||
tag = dt.tags.find(name)
|
||||
tag:delete()
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ local dtsys = require "lib/dtutils.system"
|
||||
|
||||
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
|
||||
local gettext = dt.gettext
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
du.check_min_api_version("7.0.0", "enfuse")
|
||||
|
||||
@@ -52,16 +52,13 @@ script_data.destroy_method = nil -- set to hide for libs since we can't destroy
|
||||
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
|
||||
script_data.show = nil -- only required for libs since the destroy_method only hides them
|
||||
|
||||
-- Tell gettext where to find the .mo file translating messages for a particular domain
|
||||
gettext.bindtextdomain("enfuse",dt.configuration.config_dir..PS .. "lua" .. PS .. "locale" .. PS)
|
||||
|
||||
local enf = {}
|
||||
enf.event_registered = false
|
||||
enf.module_installed = false
|
||||
enf.lib_widgets = {}
|
||||
|
||||
local function _(msgid)
|
||||
return gettext.dgettext("enfuse", msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
local function install_module()
|
||||
@@ -132,7 +129,7 @@ if enfuse_installed then
|
||||
exposure_mu = dt.new_widget("slider")
|
||||
{
|
||||
label = "exposure mu",
|
||||
tooltip = "center also known as MEAN of Gaussian weighting function (0 <= MEAN <= 1); default: 0.5",
|
||||
tooltip = _("center also known as MEAN of Gaussian weighting function (0 <= MEAN <= 1); default: 0.5"),
|
||||
hard_min = 0,
|
||||
hard_max = 1,
|
||||
value = dt.preferences.read("enfuse", "exposure_mu", "float")
|
||||
@@ -141,7 +138,7 @@ if enfuse_installed then
|
||||
exposure_mu = dt.new_widget("slider")
|
||||
{
|
||||
label = "exposure optimum",
|
||||
tooltip = "optimum exposure value, usually the maximum of the weighting function (0 <= OPTIMUM <=1); default 0.5",
|
||||
tooltip = _("optimum exposure value, usually the maximum of the weighting function (0 <= OPTIMUM <=1); default 0.5"),
|
||||
hard_min = 0,
|
||||
hard_max = 1,
|
||||
value = dt.preferences.read("enfuse", "exposure_optimum", "float")
|
||||
@@ -151,7 +148,7 @@ if enfuse_installed then
|
||||
local depth = dt.new_widget("combobox")
|
||||
{
|
||||
label = "depth",
|
||||
tooltip = "the number of bits per channel of the output image",
|
||||
tooltip = _("the number of bits per channel of the output image"),
|
||||
value = dt.preferences.read("enfuse", "depth", "integer"),
|
||||
changed_callback = function(w) dt.preferences.write("enfuse", "depth", "integer", w.selected) end,
|
||||
"8", "16", "32"
|
||||
@@ -160,14 +157,14 @@ if enfuse_installed then
|
||||
local blend_colorspace = dt.new_widget("combobox")
|
||||
{
|
||||
label = "blend colorspace",
|
||||
tooltip = "Force blending in selected colorspace",
|
||||
tooltip = _("force blending in selected colorspace"),
|
||||
changed_callback = function(w) dt.preferences.write("enfuse", "blend_colorspace", "string", w.selected) end,
|
||||
"", "identity", "ciecam"
|
||||
}
|
||||
|
||||
local enfuse_button = dt.new_widget("button")
|
||||
{
|
||||
label = enfuse_installed and "run enfuse" or "enfuse not installed",
|
||||
label = enfuse_installed and _("run enfuse") or _("enfuse not installed"),
|
||||
clicked_callback = function ()
|
||||
-- remember exposure_mu
|
||||
-- TODO: find a way to save it whenever the value changes
|
||||
@@ -185,7 +182,7 @@ if enfuse_installed then
|
||||
end
|
||||
local f = io.open(response_file, "w")
|
||||
if not f then
|
||||
dt.print(string.format(_("Error writing to `%s`"), response_file))
|
||||
dt.print(string.format(_("Error writing to '%s'"), response_file))
|
||||
os.remove(response_file)
|
||||
return
|
||||
end
|
||||
@@ -251,7 +248,7 @@ if enfuse_installed then
|
||||
..blend_colorspace_option
|
||||
.." -o \""..output_image.."\" \"@"..response_file.."\""
|
||||
if dtsys.external_command( command) > 0 then
|
||||
dt.print(_("Enfuse failed, see terminal output for details"))
|
||||
dt.print(_("enfuse failed, see terminal output for details"))
|
||||
os.remove(response_file)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -38,6 +38,12 @@ local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
require "darktable.debug"
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
du.check_min_api_version("7.0.0", "generate_image_txt")
|
||||
|
||||
-- return data structure for script_manager
|
||||
@@ -52,21 +58,21 @@ script_data.show = nil -- only required for libs since the destroy_method only h
|
||||
dt.preferences.register("generate_image_txt",
|
||||
"enabled",
|
||||
"bool",
|
||||
"create txt sidecars to display with images",
|
||||
"the txt files created get shown when the lighttable is zoomed in to one image. also enable the txt overlay setting in the gui tab",
|
||||
_("create txt sidecars to display with images"),
|
||||
_("the txt files created get shown when the lighttable is zoomed in to one image. also enable the txt overlay setting in the gui tab"),
|
||||
false)
|
||||
|
||||
dt.preferences.register("generate_image_txt",
|
||||
"command",
|
||||
"string",
|
||||
"command to generate the txt sidecar",
|
||||
"the output of this command gets written to the txt file. use $(FILE_NAME) for the image file",
|
||||
_("command to generate the txt sidecar"),
|
||||
_("the output of this command gets written to the txt file. use $(FILE_NAME) for the image file"),
|
||||
"exiv2 $(FILE_NAME)")
|
||||
|
||||
|
||||
local check_command = function(command)
|
||||
if not command:find("$(FILE_NAME)", 1, true) then
|
||||
dt.print("the command for txt sidecars looks bad. better check the preferences")
|
||||
dt.print(_("the command for txt sidecars looks bad. better check the preferences"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -32,20 +32,26 @@ USAGE
|
||||
|
||||
local dt = require "darktable"
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
local import_filter_list = {}
|
||||
local n_import_filters = 1
|
||||
|
||||
-- allow changing the filter from the preferences
|
||||
dt.preferences.register("import_filter_manager", "active_filter", "string",
|
||||
"import filter", "the name of the filter used for importing images", "")
|
||||
_("import filter"), _("the name of the filter used for importing images"), "")
|
||||
|
||||
|
||||
-- the dropdown to select the active filter from the import dialog
|
||||
local filter_dropdown = dt.new_widget("combobox")
|
||||
{
|
||||
label = "import filter",
|
||||
label = _("import filter"),
|
||||
editable = false,
|
||||
tooltip = "import filters are applied after completion of the import dialog",
|
||||
tooltip = _("import filters are applied after completion of the import dialog"),
|
||||
|
||||
changed_callback = function(widget)
|
||||
dt.preferences.write("import_filter_manager", "active_filter", "string", widget.value)
|
||||
|
||||
@@ -34,7 +34,7 @@ local dt = require "darktable"
|
||||
|
||||
-- ignore jpeg
|
||||
dt.register_import_filter("ignore jpegs", function(event, images)
|
||||
dt.print_error("ignoring all jpegs")
|
||||
dt.print_log("ignoring all jpegs")
|
||||
for i, img in ipairs(images) do
|
||||
local extension = img:match("[^.]*$"):upper()
|
||||
if (extension == "JPG") or (extension == "JPEG") then
|
||||
|
||||
@@ -38,6 +38,12 @@ local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("7.0.0", "save_selection")
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
-- return data structure for script_manager
|
||||
|
||||
local script_data = {}
|
||||
@@ -61,16 +67,16 @@ for i = 1, buffer_count do
|
||||
local saved_selection
|
||||
dt.register_event("save_selection save " .. i, "shortcut", function()
|
||||
saved_selection = dt.gui.selection()
|
||||
end, "save to buffer " .. i)
|
||||
end, string.format(_("save to buffer %d"), i))
|
||||
dt.register_event("save_selection restore " .. i, "shortcut", function()
|
||||
dt.gui.selection(saved_selection)
|
||||
end, "restore from buffer " .. i)
|
||||
end, string.format(_("restore from buffer %d"), i))
|
||||
end
|
||||
|
||||
local bounce_buffer = {}
|
||||
dt.register_event("save_selection switch", "shortcut", function()
|
||||
bounce_buffer = dt.gui.selection(bounce_buffer)
|
||||
end, "switch selection with temporary buffer")
|
||||
end, _("switch selection with temporary buffer"))
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
|
||||
@@ -38,6 +38,12 @@ local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("7.0.0", "selection_to_pdf")
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
-- return data structure for script_manager
|
||||
|
||||
local script_data = {}
|
||||
@@ -49,16 +55,16 @@ script_data.show = nil -- only required for libs since the destroy_method only h
|
||||
|
||||
dt.preferences.register
|
||||
("selection_to_pdf","Open with","string",
|
||||
"a pdf viewer",
|
||||
"Can be an absolute pathname or the tool may be in the PATH",
|
||||
_("a pdf viewer"),
|
||||
_("Can be an absolute pathname or the tool may be in the PATH"),
|
||||
"xdg-open")
|
||||
|
||||
local title_widget = dt.new_widget("entry") {
|
||||
placeholder="Title"
|
||||
placeholder = _("Title")
|
||||
}
|
||||
local no_of_thumbs_widget = dt.new_widget("slider")
|
||||
{
|
||||
label = "Thumbs per Line",
|
||||
label = _("Thumbs per Line"),
|
||||
soft_min = 1, -- The soft minimum value for the slider, the slider can't go beyond this point
|
||||
soft_max = 10, -- The soft maximum value for the slider, the slider can't go beyond this point
|
||||
hard_min = 1, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point
|
||||
@@ -66,10 +72,10 @@ local no_of_thumbs_widget = dt.new_widget("slider")
|
||||
value = 4 -- The current value of the slider
|
||||
}
|
||||
local widget = dt.new_widget("box") {
|
||||
orientation=horizontal,
|
||||
dt.new_widget("label"){label = "Title:"},
|
||||
orientation = horizontal,
|
||||
dt.new_widget("label"){label = _("Title:")},
|
||||
title_widget,
|
||||
dt.new_widget("label"){label = "Thumbnails per row:"},
|
||||
dt.new_widget("label"){label = _("Thumbnails per row:")},
|
||||
no_of_thumbs_widget
|
||||
}
|
||||
|
||||
@@ -116,7 +122,7 @@ local function destroy()
|
||||
dt.print_log("done destroying")
|
||||
end
|
||||
|
||||
dt.register_storage("export_pdf","Export thumbnails to pdf",
|
||||
dt.register_storage(_("export_pdf"),_("Export thumbnails to pdf"),
|
||||
nil,
|
||||
function(storage,image_table)
|
||||
local my_title = title_widget.text
|
||||
@@ -163,7 +169,7 @@ dt.register_storage("export_pdf","Export thumbnails to pdf",
|
||||
local command = "pdflatex -halt-on-error -output-directory "..dir.." "..locfile
|
||||
local result = dt.control.execute(command)
|
||||
if result ~= 0 then
|
||||
dt.print("Problem running pdflatex") -- this one is probably usefull to the user
|
||||
dt.print(_("Problem running pdflatex")) -- this one is probably usefull to the user
|
||||
error("Problem running "..command)
|
||||
end
|
||||
|
||||
@@ -173,7 +179,7 @@ dt.register_storage("export_pdf","Export thumbnails to pdf",
|
||||
command = command.." "..pdffile
|
||||
local result = dt.control.execute(command)
|
||||
if result ~= 0 then
|
||||
dt.print("Problem running pdf viewer") -- this one is probably usefull to the user
|
||||
dt.print(_("Problem running pdf viewer")) -- this one is probably usefull to the user
|
||||
error("Problem running "..command)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user