From 66b33d6f48c496ce64fe1ef6f835d790b1b7858a Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 20 Jan 2024 20:22:32 -0500 Subject: [PATCH] updated contrib scripts to use darktable translation facilities --- contrib/AutoGrouper.lua | 6 ++-- contrib/CollectHelper.lua | 7 ++-- contrib/HDRMerge.lua | 10 +++--- contrib/LabelsToTags.lua | 50 ++++++++++++++++------------- contrib/OpenInExplorer.lua | 7 ++-- contrib/RL_out_sharp.lua | 8 ++--- contrib/autostyle.lua | 24 ++++++++------ contrib/change_group_leader.lua | 7 ++-- contrib/clear_GPS.lua | 6 ++-- contrib/color_profile_manager.lua | 11 +++---- contrib/copy_attach_detach_tags.lua | 7 ++-- contrib/cr2hdr.lua | 14 +++++--- contrib/cycle_group_leader.lua | 7 ++-- contrib/enfuseAdvanced.lua | 22 ++++++------- contrib/exportLUT.lua | 8 ++--- contrib/ext_editor.lua | 24 +++++++------- contrib/face_recognition.lua | 13 +++----- contrib/fujifilm_ratings.lua | 10 +++--- contrib/geoJSON_export.lua | 7 ++-- contrib/geoToolbox.lua | 15 ++++----- contrib/gimp.lua | 9 ++---- contrib/gpx_export.lua | 9 ++---- contrib/harmonic_armature_guide.lua | 7 ++-- contrib/hif_group_leader.lua | 7 ++-- contrib/hugin.lua | 11 +++---- contrib/image_stack.lua | 19 +++++------ contrib/image_time.lua | 16 ++++----- contrib/jpg_group_leader.lua | 7 ++-- contrib/kml_export.lua | 7 ++-- contrib/passport_guide.lua | 7 ++-- contrib/pdf_slideshow.lua | 13 +++----- contrib/photils.lua | 8 ++--- contrib/quicktag.lua | 7 ++-- contrib/rate_group.lua | 24 ++++++++------ contrib/rename-tags.lua | 28 +++++++++------- contrib/rename_images.lua | 17 ++++------ contrib/select_non_existing.lua | 5 ++- contrib/select_untagged.lua | 7 ++-- contrib/slideshowMusic.lua | 11 +++---- contrib/transfer_hierarchy.lua | 12 +++---- contrib/video_ffmpeg.lua | 9 +++--- 41 files changed, 224 insertions(+), 279 deletions(-) diff --git a/contrib/AutoGrouper.lua b/contrib/AutoGrouper.lua index 79ded8c..decc9b9 100644 --- a/contrib/AutoGrouper.lua +++ b/contrib/AutoGrouper.lua @@ -52,12 +52,10 @@ 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 -local gettext = dt.gettext --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("AutoGrouper",dt.configuration.config_dir.."/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext("AutoGrouper", msgid) + return gettext(msgid) end local Ag = {} diff --git a/contrib/CollectHelper.lua b/contrib/CollectHelper.lua index 7f60935..9e6f12c 100644 --- a/contrib/CollectHelper.lua +++ b/contrib/CollectHelper.lua @@ -47,13 +47,10 @@ In the "Selected Images" module click on "Collect on this Image" local dt = require "darktable" local du = require "lib/dtutils" -local gettext = dt.gettext +local gettext = dt.gettext.gettext local previous = nil local all_active = false --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("CollectHelper",dt.configuration.config_dir.."/lua/locale/") - du.check_min_api_version("7.0.0", "CollectHelper") -- return data structure for script_manager @@ -66,7 +63,7 @@ script_data.restart = nil -- how to restart the (lib) script after it's been hid script_data.show = nil -- only required for libs since the destroy_method only hides them local function _(msgid) - return gettext.dgettext("CollectHelper", msgid) + return gettext(msgid) end -- FUNCTION -- diff --git a/contrib/HDRMerge.lua b/contrib/HDRMerge.lua index 3e7e29a..a662f21 100644 --- a/contrib/HDRMerge.lua +++ b/contrib/HDRMerge.lua @@ -67,10 +67,10 @@ if dt.configuration.running_os == 'windows' then os_path_seperator = '\\' end local CURR_API_STRING = dt.configuration.api_version_string -- Tell gettext where to find the .mo file translating messages for a particular domain -local gettext = dt.gettext -gettext.bindtextdomain('HDRMerge', dt.configuration.config_dir..'/lua/locale/') +local gettext = dt.gettext.gettext + local function _(msgid) - return gettext.dgettext('HDRMerge', msgid) + return gettext(msgid) end local temp @@ -208,7 +208,7 @@ end local function main() PreCall({HDRM}) --check if furst run then check if install OK if HDRM.install_error then - dt.print_error(_('HDRMerge install issue')) + dt.print_error('HDRMerge install issue') dt.print(_('HDRMerge install issue, please ensure the binary path is proper')) return end @@ -277,7 +277,7 @@ local function main() end dt.print(_('HDRMerge completed successfully')) else - dt.print_error(_('HDRMerge failed')) + dt.print_error('HDRMerge failed') dt.print(_('HDRMerge failed')) end diff --git a/contrib/LabelsToTags.lua b/contrib/LabelsToTags.lua index a89b05d..83feada 100644 --- a/contrib/LabelsToTags.lua +++ b/contrib/LabelsToTags.lua @@ -52,6 +52,12 @@ local du = require "lib/dtutils" du.check_min_api_version("7.0.0", "LabelsToTags") +local gettext = dt.gettext.gettext + +local function _(msgid) + return gettext(msgid) +end + -- return data structure for script_manager local script_data = {} @@ -68,7 +74,7 @@ local ltt = {} ltt.module_installed = false ltt.event_registered = false -local LIB_ID = "LabelsToTags" +local LIB_ID = _("LabelsToTags") -- Helper functions: BEGIN @@ -109,23 +115,23 @@ end local initialAvailableMappings = { - ["Colors"] = { ["+*****"] = { "Red" }, - ["*+****"] = { "Yellow" }, - ["**+***"] = { "Green" }, - ["***+**"] = { "Blue" }, - ["****+*"] = { "Purple" } }, - ["Single colors"] = { ["+----*"] = { "Red", "Only red" }, - ["-+---*"] = { "Yellow", "Only yellow" }, - ["--+--*"] = { "Green", "Only green" }, - ["---+-*"] = { "Blue", "Only blue" }, - ["----+*"] = { "Purple", "Only purple" } }, - ["Ratings"] = { ["*****0"] = { "No stars", "Not rejected" }, - ["*****1"] = { "One star", "Not rejected" }, - ["*****2"] = { "Two stars", "Not rejected" }, - ["*****3"] = { "Three stars", "Not rejected" }, - ["*****4"] = { "Four stars", "Not rejected" }, - ["*****5"] = { "Five stars", "Not rejected" }, - ["*****R"] = { "Rejected" } } + [_("Colors")] = { ["+*****"] = { _("Red") }, + ["*+****"] = { _("Yellow") }, + ["**+***"] = { _("Green") }, + ["***+**"] = { _("Blue") }, + ["****+*"] = { _("Purple") } }, + [_("Single colors")] = { ["+----*"] = { _("Red"), _("Only red") }, + ["-+---*"] = { _("Yellow"), _("Only yellow") }, + ["--+--*"] = { _("Green"), _("Only green") }, + ["---+-*"] = { _("Blue"), _("Only blue") }, + ["----+*"] = { _("Purple"), _("Only purple") } }, + [_("Ratings")] = { ["*****0"] = { _("No stars"), _("Not rejected") }, + ["*****1"] = { _("One star"), _("Not rejected") }, + ["*****2"] = { _("Two stars"), _("Not rejected") }, + ["*****3"] = { _("Three stars"), _("Not rejected") }, + ["*****4"] = { _("Four stars"), _("Not rejected") }, + ["*****5"] = { _("Five stars"), _("Not rejected") }, + ["*****R"] = { _("Rejected") } } } local availableMappings = {} @@ -140,14 +146,14 @@ end local function getComboboxTooltip() if availableMappings == nil or next(availableMappings) == nil then - return("No registered mappings -- using defaults") + return(_("No registered mappings -- using defaults")) else - return("Select a label-to-tag mapping") + return(_("Select a label-to-tag mapping")) end end local mappingComboBox = darktable.new_widget("combobox"){ - label = "mapping", + label = _("mapping"), value = 1, tooltip = getComboboxTooltip(), reset_callback = function(selfC) @@ -170,7 +176,7 @@ local mappingComboBox = darktable.new_widget("combobox"){ } local function doTagging(selfC) - local job = darktable.gui.create_job(string.format("labels to tags (%d image" .. (#(darktable.gui.action_images) == 1 and "" or "s") .. ")",#(darktable.gui.action_images)),true) + local job = darktable.gui.create_job(string.format(_("labels to tags (%d image%s)"), #(darktable.gui.action_images), (#(darktable.gui.action_images) == 1 and "" or "s")), true) job.percent = 0.0 local pctIncrement = 1.0 / #(darktable.gui.action_images) diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua index 9a8cd65..443a09a 100644 --- a/contrib/OpenInExplorer.lua +++ b/contrib/OpenInExplorer.lua @@ -51,7 +51,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" local dsys = require "lib/dtutils.system" -local gettext = dt.gettext +local gettext = dt.gettext.gettext --Check API version du.check_min_api_version("7.0.0", "OpenInExplorer") @@ -65,11 +65,8 @@ 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("OpenInExplorer",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("OpenInExplorer", msgid) + return gettext(msgid) end local act_os = dt.configuration.running_os diff --git a/contrib/RL_out_sharp.lua b/contrib/RL_out_sharp.lua index 2c854e4..44d961e 100644 --- a/contrib/RL_out_sharp.lua +++ b/contrib/RL_out_sharp.lua @@ -78,10 +78,10 @@ script_data.show = nil -- only required for libs since the destroy_method only h local PS = dt.configuration.running_os == "windows" and "\\" or "/" -- translation -local gettext = dt.gettext -gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS) +local gettext = dt.gettext.gettext + local function _(msgid) - return gettext.dgettext(MODULE_NAME, msgid) + return gettext(msgid) end -- initialize module preferences @@ -137,7 +137,7 @@ local function export2RL(storage, image_table, extra_data) for image, temp_name in pairs(image_table) do i = i + 1 - dt.print(_("sharpening image ")..i.." ...") + dt.print(string.format(_("sharpening image %d ..."), i)) -- create unique filename new_name = output_folder..PS..df.get_basename(temp_name)..".jpg" new_name = df.create_unique_filename(new_name) diff --git a/contrib/autostyle.lua b/contrib/autostyle.lua index 53fc0ab..cf3ebe7 100644 --- a/contrib/autostyle.lua +++ b/contrib/autostyle.lua @@ -42,6 +42,12 @@ local filelib = require "lib/dtutils.file" du.check_min_api_version("7.0.0", "autostyle") +local gettext = darktable.gettext.gettext + +local function _(msgid) + return gettext(msgid) +end + -- return data structure for script_manager local script_data = {} @@ -92,19 +98,19 @@ local function autostyle_apply_one_image (image) -- check they all exist (correct syntax) if (not tag) then - darktable.print("EXIF TAG not found in " .. pref) + darktable.print(string.format(_("EXIF TAG not found in %s"), pref)) return 0 end if (not value) then - darktable.print("value to match not found in " .. pref) + darktable.print(string.format(_("value to match not found in %s"), pref)) return 0 end if (not style_name) then - darktable.print("style name not found in " .. pref) + darktable.print(string.format(_("style name not found in %s"), pref)) return 0 end if not filelib.check_if_bin_exists("exiftool") then - darktable.print("Can't find exiftool") + darktable.print(_("Can't find exiftool")) return 0 end @@ -118,7 +124,7 @@ local function autostyle_apply_one_image (image) end end if (not style) then - darktable.print("style not found for autostyle: " .. style_name) + darktable.print(string.format(_("style not found for autostyle: %s"), style_name)) return 0 end @@ -127,7 +133,7 @@ local function autostyle_apply_one_image (image) --darktable.print_error("dr_attr:" .. auto_dr_attr) -- If the lookup fails, stop here if (not ok) then - darktable.print("Couldn't get attribute " .. auto_dr_attr .. " from exiftool's output") + darktable.print(string.format(_("Couldn't get attribute %s from exiftool's output"), auto_dr_attr)) return 0 end if auto_dr_attr == value then @@ -154,7 +160,7 @@ local function autostyle_apply(shortcut) images_submitted = images_submitted + 1 images_processed = images_processed + autostyle_apply_one_image(image) end - darktable.print("Applied auto style to " .. images_processed .. " out of " .. images_submitted .. " image(s)") + darktable.print(string.format(_("Applied auto style to %d out of %d image(s)"), images_processed, images_submitted)) end local function destroy() @@ -164,9 +170,9 @@ end -- Registering events darktable.register_event("autostyle", "shortcut", autostyle_apply, - "Apply your chosen style from exiftool tags") + _("Apply your chosen style from exiftool tags")) -darktable.preferences.register("autostyle", "exif_tag", "string", "Autostyle: EXIF_tag=value=>style", "apply a style automatically if an EXIF_tag matches value. Find the tag with exiftool", "") +darktable.preferences.register("autostyle", "exif_tag", "string", "Autostyle: EXIF_tag=value=>style", _("apply a style automatically if an EXIF_tag matches value. Find the tag with exiftool"), "") darktable.register_event("autostyle", "post-import-image", autostyle_apply_one_image_event) diff --git a/contrib/change_group_leader.lua b/contrib/change_group_leader.lua index c7fe5c0..786c91e 100644 --- a/contrib/change_group_leader.lua +++ b/contrib/change_group_leader.lua @@ -36,7 +36,7 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" -local gettext = dt.gettext +local gettext = dt.gettext.gettext local MODULE = "change_group_leader" @@ -51,11 +51,8 @@ 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(MODULE, dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext(MODULE, msgid) + return gettext(msgid) end -- create a namespace to contain persistent data and widgets diff --git a/contrib/clear_GPS.lua b/contrib/clear_GPS.lua index da4668c..9f21b1e 100644 --- a/contrib/clear_GPS.lua +++ b/contrib/clear_GPS.lua @@ -48,18 +48,16 @@ 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 -local gettext = dt.gettext +local gettext = dt.gettext.gettext -- not a number local NaN = 0/0 du.check_min_api_version("7.0.0", "clear_GPS") --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("clear_GPS",dt.configuration.config_dir.."/lua/locale/") local function _(msgid) - return gettext.dgettext("clear_GPS", msgid) + return gettext(msgid) end local function clear_GPS(images) diff --git a/contrib/color_profile_manager.lua b/contrib/color_profile_manager.lua index bd09755..b8ef21f 100644 --- a/contrib/color_profile_manager.lua +++ b/contrib/color_profile_manager.lua @@ -52,13 +52,10 @@ du.check_min_api_version("7.0.0", "color_profile_manager") -- L O C A L I Z A T I O N -- - - - - - - - - - - - - - - - - - - - - - - - -local gettext = dt.gettext - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("color_profile_manager", dt.configuration.config_dir .. "/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext("color_profile_manager", msgid) + return gettext(msgid) end -- - - - - - - - - - - - - - - - - - - - - - - - @@ -119,13 +116,13 @@ end local function add_profile(file, dir) df.file_copy(file, dir) - dt.print(_("added color profile " .. file .. " to " .. dir)) + dt.print(string.format(_("added color profile %s to %s"), file, dir)) dt.print_log("color profile " .. file .. " added to " .. dir) end local function remove_profile(file, dir) os.remove(dir .. PS .. file) - dt.print(_("removed color profile " .. file .. " from " .. dir)) + dt.print(string.format(_("removed color profile %s from %s"), file, dir)) dt.print_log("color profile " .. file .. " removed from " .. dir) end diff --git a/contrib/copy_attach_detach_tags.lua b/contrib/copy_attach_detach_tags.lua index 05f6f1f..1de8db2 100644 --- a/contrib/copy_attach_detach_tags.lua +++ b/contrib/copy_attach_detach_tags.lua @@ -40,7 +40,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local debug = require "darktable.debug" -local gettext = dt.gettext +local gettext = dt.gettext.gettext du.check_min_api_version("7.0.0", "copy_attach_detach_tags") @@ -53,11 +53,8 @@ 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("copy_attach_detach_tags",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("copy_attach_detach_tags", msgid) + return gettext(msgid) end local cadt = {} diff --git a/contrib/cr2hdr.lua b/contrib/cr2hdr.lua index f4a40c9..53b1e14 100644 --- a/contrib/cr2hdr.lua +++ b/contrib/cr2hdr.lua @@ -37,6 +37,12 @@ local du = require "lib/dtutils" du.check_min_api_version("7.0.0", "cr2hdr") +local gettext = dt.gettext.gettext + +local function _(msgid) + return gettext(msgid) +end + -- return data structure for script_manager local script_data = {} @@ -87,7 +93,7 @@ end local function convert_images() if next(queue) == nil then return end - job = darktable.gui.create_job("Dual ISO conversion", true, stop_conversion) + job = darktable.gui.create_job(_("Dual ISO conversion"), true, stop_conversion) for key,image in pairs(queue) do if job.valid then job.percent = (key-1)/#queue @@ -98,7 +104,7 @@ local function convert_images() end local success_count = 0 for _ in pairs(processed_files) do success_count = success_count + 1 end - darktable.print("Dual ISO conversion successful on " .. success_count .. "/" .. #queue .. " images.") + darktable.print(string.format(_("Dual ISO conversion successful on %d/%d images."), success_count, #queue)) job.valid = false processed_files = {} queue = {} @@ -122,13 +128,13 @@ local function destroy() end darktable.register_event("cr2hdr", "shortcut", - convert_action_images, "Run cr2hdr (Magic Lantern DualISO converter) on selected images") + convert_action_images, _("Run cr2hdr (Magic Lantern DualISO converter) on selected images")) darktable.register_event("cr2hdr", "post-import-image", file_imported) darktable.register_event("cr2hdr", "post-import-film", film_imported) -darktable.preferences.register("cr2hdr", "onimport", "bool", "Invoke on import", "If true then cr2hdr will try to proccess every file during importing. Warning: cr2hdr is quite slow even in figuring out on whether the file is Dual ISO or not.", false) +darktable.preferences.register("cr2hdr", "onimport", "bool", _("Invoke on import"), _("If true then cr2hdr will try to proccess every file during importing. Warning: cr2hdr is quite slow even in figuring out on whether the file is Dual ISO or not."), false) script_data.destroy = destroy diff --git a/contrib/cycle_group_leader.lua b/contrib/cycle_group_leader.lua index e4bdd11..dde8546 100644 --- a/contrib/cycle_group_leader.lua +++ b/contrib/cycle_group_leader.lua @@ -69,13 +69,10 @@ script_data.show = nil -- only required for libs since the destroy_method only h -- I 1 8 N -- - - - - - - - - - - - - - - - - - - - - - - - - - -local gettext = dt.gettext - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain(MODULE, dt.configuration.config_dir .. "/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext(MODULE, msgid) + return gettext(msgid) end -- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/enfuseAdvanced.lua b/contrib/enfuseAdvanced.lua index 76ffd01..f8aeb9b 100644 --- a/contrib/enfuseAdvanced.lua +++ b/contrib/enfuseAdvanced.lua @@ -77,10 +77,10 @@ script_data.restart = nil -- how to restart the (lib) script after it's been hid 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 -local gettext = dt.gettext -gettext.bindtextdomain('enfuseAdvanced',dt.configuration.config_dir..'/lua/locale/') +local gettext = dt.gettext.gettext + local function _(msgid) - return gettext.dgettext('enfuseAdvanced', msgid) + return gettext(msgid) end -- INITS -- @@ -260,7 +260,7 @@ local function ExeUpdate(prog_tbl) --updates executable paths and verifies them if not prog.bin then prog.install_error = true dt.preferences.write(mod, 'bin_exists', 'bool', false) - dt.print(_('issue with ')..prog.name.._(' executable')) + dt.print(string.format(_("issue with %s executable"), prog.name)) else prog.bin = CleanSpaces(prog.bin) end @@ -377,7 +377,7 @@ local function SaveToPreference(preset) --save the present values of enfuse GUI dt.preferences.write(mod, preset..argument, arg_data.style, temp) end end - dt.print(_('saved to ')..preset) + dt.print(string.format(_("saved to %s"), preset)) end local function LoadFromPreference(preset) --load values from the specified 'preset' into the GUI elements @@ -393,7 +393,7 @@ local function LoadFromPreference(preset) --load values from the specified 'pres dt.preferences.write(mod, 'active_'..argument, arg_data.style, temp) end end - dt.print(_('loaded from ')..preset) + dt.print(string.format(_("loaded from %s"), preset)) end local function remove_temp_files(images_to_remove) --deletes all files specified by the input string @@ -428,7 +428,7 @@ local function support_format(storage, format) --tells dt we only support TIFF e end local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) --outputs message to user showing script export status - dt.print(_('export for image fusion ')..tostring(math.floor(number))..' / '..tostring(math.floor(total))) + dt.print(string.format(_("export for image fusion %d / %d"), math.floor(number), math.floor(total))) end local function main(storage, image_table, extra_data) @@ -456,8 +456,8 @@ local function main(storage, image_table, extra_data) job.valid = false if resp ~= 0 then remove_temp_files(images_to_remove) - dt.print_error(AIS.name.._(' failed')) - dt.print(AIS.name.._(' failed')) + dt.print(string.format(_("%s failed"), AIS.name)) + dt.print_error(AIS.name .. ' failed') return end end @@ -483,8 +483,8 @@ local function main(storage, image_table, extra_data) local resp = dsys.external_command(run_cmd) if resp ~= 0 then remove_temp_files(images_to_remove) - dt.print_error(ENF.name.._(' failed')) - dt.print(ENF.name.._(' failed')) + dt.print_error(ENF.name..' failed') + dt.print(string.format(_("%s failed"), ENF.name)) return end diff --git a/contrib/exportLUT.lua b/contrib/exportLUT.lua index fe11960..6a22f83 100644 --- a/contrib/exportLUT.lua +++ b/contrib/exportLUT.lua @@ -42,12 +42,10 @@ 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 -local gettext = dt.gettext - -gettext.bindtextdomain("exportLUT",dt.configuration.config_dir.."/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext("exportLUT", msgid) + return gettext(msgid) end du.check_min_api_version("5.0.0", "exportLUT") @@ -127,7 +125,7 @@ local function export_luts() io_lut:write_image(identity, output_path(style.name, job)) count = count + 1 job.percent = count / size - dt.print(_("Exported: ") .. output_path(style.name, job)) + dt.print(string.format(_("Exported: %s"), output_path(style.name, job))) end dt.print(_("Done exporting haldCLUTs")) job.valid = false diff --git a/contrib/ext_editor.lua b/contrib/ext_editor.lua index 827d527..b28a7f9 100644 --- a/contrib/ext_editor.lua +++ b/contrib/ext_editor.lua @@ -95,10 +95,10 @@ ee.widgets = {} -- translation -local gettext = dt.gettext -gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS) +local gettext = dt.gettext.gettext + local function _(msgid) - return gettext.dgettext(MODULE_NAME, msgid) + return gettext(msgid) end -- maximum number of external programs, can be increased to necessity @@ -156,7 +156,7 @@ local function UpdateProgramList(combobox, button_edit, button_edit_copy, update button_edit.sensitive = active button_edit_copy.sensitive = active - if update_button_pressed then dt.print(n_entries.._(" editors configured")) end + if update_button_pressed then dt.print(string.format(_("%d editors configured"), n_entries)) end end @@ -223,17 +223,17 @@ local function OpenWith(images, choice, copy) -- physical copy, check result, return if error local copy_success = df.file_copy(name, new_name) if not copy_success then - dt.print(_("error copying file ")..name) + dt.print(string.format(_("error copying file %s"), name)) return end end -- launch the external editor, check result, return if error local run_cmd = bin.." "..df.sanitize_filename(new_name) - dt.print(_("launching ")..friendly_name.."...") + dt.print(string.format(_("launching %s..."), friendly_name)) local result = dtsys.external_command(run_cmd) if result ~= 0 then - dt.print(_("error launching ")..friendly_name) + dt.print(string.format(_("error launching %s"), friendly_name)) return end @@ -326,7 +326,7 @@ local function export2collection(storage, image_table, extra_data) -- move image to collection folder, check result, return if error move_success = df.file_move(temp_name, new_name) if not move_success then - dt.print(_("error moving file ")..temp_name) + dt.print(string.format(_("error moving file %s"), temp_name)) return end @@ -378,7 +378,7 @@ end local function restart() for i = 1, MAX_EDITORS do dt.register_event(MODULE_NAME .. i, "shortcut", - program_shortcut, _("edit with program ")..string.format("%02d", i)) + program_shortcut, string.format(_("edit with program %02d"), i)) end dt.register_storage("exp2coll", _("collection"), nil, export2collection) dt.gui.libs[MODULE_NAME].visible = true @@ -476,11 +476,11 @@ dt.register_storage("exp2coll", _("collection"), nil, export2collection) -- register the new preferences ----------------------------------------------- for i = MAX_EDITORS, 1, -1 do dt.preferences.register(MODULE_NAME, "program_path_"..i, "file", - _("executable for external editor ")..i, + string.format(_("executable for external editor %d"), i), _("select executable for external editor") , _("(None)")) dt.preferences.register(MODULE_NAME, "program_name_"..i, "string", - _("name of external editor ")..i, + string.format(_("name of external editor %d"), i), _("friendly name of external editor"), "") end dt.preferences.register(MODULE_NAME, "show_in_darkrooom", "bool", @@ -491,7 +491,7 @@ dt.preferences.register(MODULE_NAME, "show_in_darkrooom", "bool", -- register the new shortcuts ------------------------------------------------- for i = 1, MAX_EDITORS do dt.register_event(MODULE_NAME .. i, "shortcut", - program_shortcut, _("edit with program ")..string.format("%02d", i)) + program_shortcut, string.format(_("edit with program %02d"), i)) end diff --git a/contrib/face_recognition.lua b/contrib/face_recognition.lua index 5bd7048..7325d7e 100644 --- a/contrib/face_recognition.lua +++ b/contrib/face_recognition.lua @@ -44,7 +44,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" local dtsys = require "lib/dtutils.system" -local gettext = dt.gettext +local gettext = dt.gettext.gettext -- constants @@ -69,11 +69,8 @@ local fc = {} fc.module_installed = false fc.event_registered = false --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("face_recognition", dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("face_recognition", msgid) + return gettext(msgid) end local function build_image_table(images) @@ -399,7 +396,7 @@ fc.category_tags = dt.new_widget("entry"){ fc.tolerance = dt.new_widget("slider"){ label = _("tolerance"), - tooltip = ("detection tolerance - 0.6 default - lower if too many faces detected"), + tooltip = _("detection tolerance - 0.6 default - lower if too many faces detected"), soft_min = 0.0, hard_min = 0.0, soft_max = 1.0, @@ -482,12 +479,12 @@ table.insert(widgets, fc.num_cores) table.insert(widgets, fc.export_format) table.insert(widgets, dt.new_widget("box"){ orientation = "horizontal", - dt.new_widget("label"){ label = _("width ")}, + dt.new_widget("label"){ label = _("width")}, fc.width, }) table.insert(widgets, dt.new_widget("box"){ orientation = "horizontal", - dt.new_widget("label"){ label = _("height ")}, + dt.new_widget("label"){ label = _("height")}, fc.height, }) table.insert(widgets, fc.execute) diff --git a/contrib/fujifilm_ratings.lua b/contrib/fujifilm_ratings.lua index c6b8738..c64fffa 100644 --- a/contrib/fujifilm_ratings.lua +++ b/contrib/fujifilm_ratings.lua @@ -26,7 +26,7 @@ Dependencies: local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" -local gettext = dt.gettext +local gettext = dt.gettext.gettext du.check_min_api_version("7.0.0", "fujifilm_ratings") @@ -39,10 +39,8 @@ 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 -gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("fujifilm_ratings", msgid) + return gettext(msgid) end local function detect_rating(event, image) @@ -60,7 +58,7 @@ local function detect_rating(event, image) if string.len(jpeg_result) > 0 then jpeg_result = string.gsub(jpeg_result, "^Rating.*(%d)", "%1") image.rating = tonumber(jpeg_result) - dt.print_error(_("Using JPEG Rating: ") .. tostring(jpeg_result)) + dt.print_error(string.format(_("Using JPEG Rating: %d"), jpeg_result)) return end command = "exiftool -Rating " .. RAF_filename @@ -71,7 +69,7 @@ local function detect_rating(event, image) if string.len(raf_result) > 0 then raf_result = string.gsub(raf_result, "^Rating.*(%d)", "%1") image.rating = tonumber(raf_result) - dt.print_error(_("Using RAF Rating: ") .. tostring(raf_result)) + dt.print_error(string.format(_("Using RAF Rating: %d"), raf_result)) end end diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index cd748fe..dac5f5f 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -35,7 +35,7 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" -local gettext = dt.gettext +local gettext = dt.gettext.gettext du.check_min_api_version("7.0.0", "geoJSON_export") @@ -48,11 +48,8 @@ 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("geoJSON_export",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("geoJSON_export", msgid) + return gettext(msgid) end -- Sort a table diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 30f9040..b595015 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -28,7 +28,7 @@ require "geoToolbox" local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" -local gettext = dt.gettext +local gettext = dt.gettext.gettext du.check_min_api_version("7.0.0", "geoToolbox") @@ -41,11 +41,8 @@ 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("geoToolbox",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("geoToolbox", msgid) + return gettext(msgid) end @@ -300,9 +297,9 @@ local function copy_gps() end end - label_copy_gps_lat.label = _("latitude: ") .. copy_gps_latitude - label_copy_gps_lon.label = _("longitude: ") ..copy_gps_longitude - label_copy_gps_ele.label = _("elevation: ") .. copy_gps_elevation + label_copy_gps_lat.label = string.format(_("latitude: "), copy_gps_latitude) + label_copy_gps_lon.label = string.format(_("longitude: "),copy_gps_longitude) + label_copy_gps_ele.label = string.format(_("elevation: "), copy_gps_elevation) return end @@ -582,7 +579,7 @@ local function altitude_profile() file = io.open(exportDirectory.."/"..exportFilename, "w") file:write(csv_file) file:close() - dt.print(_("File created in ")..exportDirectory) + dt.print(string.format(_("File created in %s"), exportDirectory)) end diff --git a/contrib/gimp.lua b/contrib/gimp.lua index 0b235f9..843bbce 100644 --- a/contrib/gimp.lua +++ b/contrib/gimp.lua @@ -69,7 +69,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" local dtsys = require "lib/dtutils.system" -local gettext = dt.gettext +local gettext = dt.gettext.gettext local gimp_widget = nil du.check_min_api_version("7.0.0", "gimp") @@ -83,11 +83,8 @@ 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("gimp",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("gimp", msgid) + return gettext(msgid) end local function group_if_not_member(img, new_img) @@ -119,7 +116,7 @@ local function gimp_edit(storage, image_table, extra_data) --finalize local gimp_executable = df.check_if_bin_exists("gimp") if not gimp_executable then - dt.print_error(_("GIMP not found")) + dt.print_error("GIMP not found") return end diff --git a/contrib/gpx_export.lua b/contrib/gpx_export.lua index c25028e..6e29c8e 100644 --- a/contrib/gpx_export.lua +++ b/contrib/gpx_export.lua @@ -25,7 +25,7 @@ For each source folder, a separate is generated in the gpx file. local dt = require "darktable" local df = require "lib/dtutils.file" local dl = require "lib/dtutils" -local gettext = dt.gettext +local gettext = dt.gettext.gettext dl.check_min_api_version("7.0.0", "gpx_export") @@ -38,9 +38,6 @@ 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("gpx_export",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) return gettext.dgettext("gpx_export", msgid) end @@ -132,11 +129,11 @@ local function create_gpx_file() local file = io.open(path, "w") if (file == nil) then - dt.print(_("invalid path: ")..path) + dt.print(string.format(_("invalid path: %s"), path)) else file:write(gpx_file) file:close() - dt.print(_("gpx file created: ")..path) + dt.print(string.format(_("gpx file created: "), path)) end end diff --git a/contrib/harmonic_armature_guide.lua b/contrib/harmonic_armature_guide.lua index e5c23f2..308c5ef 100644 --- a/contrib/harmonic_armature_guide.lua +++ b/contrib/harmonic_armature_guide.lua @@ -32,15 +32,12 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" -local gettext = dt.gettext +local gettext = dt.gettext.gettext du.check_min_api_version("2.0.0", "harmonic_armature_guide") --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("harmonic_armature_guide",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("harmonic_armature_guide", msgid) + return gettext(msgid) end dt.guides.register_guide("harmonic armature", diff --git a/contrib/hif_group_leader.lua b/contrib/hif_group_leader.lua index 5fa0aa5..14327db 100644 --- a/contrib/hif_group_leader.lua +++ b/contrib/hif_group_leader.lua @@ -73,13 +73,10 @@ script_data.show = nil -- only required for libs since the destroy_method only h -- I 1 8 N -- - - - - - - - - - - - - - - - - - - - - - - - - - -local gettext = dt.gettext - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain(MODULE, dt.configuration.config_dir .. "/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext(MODULE, msgid) + return gettext(msgid) end diff --git a/contrib/hugin.lua b/contrib/hugin.lua index 77ad7cb..6621a18 100644 --- a/contrib/hugin.lua +++ b/contrib/hugin.lua @@ -40,7 +40,7 @@ local du = require "lib/dtutils" local df = require "lib/dtutils.file" local log = require "lib/dtutils.log" local dtsys = require "lib/dtutils.system" -local gettext = dt.gettext +local gettext = dt.gettext.gettext local namespace = 'module_hugin' local user_pref_str = 'prefer_gui' @@ -65,11 +65,8 @@ 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("hugin",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("hugin", msgid) + return gettext(msgid) end local function user_preference_changed(widget) @@ -201,7 +198,7 @@ local function create_panorama(storage, image_table, extra_data) --finalize if df.check_if_file_exists(src_path) then log.msg(log.debug, "found ", src_path, " importing to ", dst_path) df.file_move(src_path, dst_path) - dt.print(_("importing file "..dst_path)) + dt.print(string.format(_("importing file %s"), dst_path)) dt.database.import(dst_path) end end @@ -227,7 +224,7 @@ hugin_widget = dt.new_widget("box") { orientation = "vertical", dt.new_widget("check_button") { - label = _(" launch hugin gui"), + label = _("launch hugin gui"), value = user_prefer_gui, tooltip = _('launch hugin in gui mode'), clicked_callback = user_preference_changed diff --git a/contrib/image_stack.lua b/contrib/image_stack.lua index b78b96c..d8abc9a 100644 --- a/contrib/image_stack.lua +++ b/contrib/image_stack.lua @@ -64,7 +64,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" local dtsys = require "lib/dtutils.system" -local gettext = dt.gettext +local gettext = dt.gettext.gettext local job = nil -- path separator constant @@ -82,11 +82,8 @@ 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("image_stack",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("image_stack", msgid) + return gettext(msgid) end -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -452,7 +449,7 @@ local function copy_image_attributes(from, to, ...) to.rights = from.rights to.description = from.description else - dt.print_error(_("Unrecognized option to copy_image_attributes: " .. arg)) + dt.print_error("Unrecognized option to copy_image_attributes: " .. arg) end end end @@ -496,7 +493,7 @@ local function image_stack(storage, image_table, extra_data) if image_count < 2 then dt.print(_("ERROR: at least 2 images required for image stacking, exiting...")) - dt.print_error(_(image_count .. " image(s) selected, at least 2 required")) + dt.print_error(image_count .. " image(s) selected, at least 2 required") return end @@ -520,13 +517,13 @@ local function image_stack(storage, image_table, extra_data) job.percent = job.percent + percent_step else dt.print(_("ERROR: image alignment failed")) - dt.print_error(_("image alignment failed")) + dt.print_error("image alignment failed") cleanup(img_list) return end else dt.print(_("ERROR: align_image_stack not found")) - dt.print_error(_("align_image_stack not found")) + dt.print_error("align_image_stack not found") cleanup(img_list) return end @@ -540,7 +537,7 @@ local function image_stack(storage, image_table, extra_data) local ignore_tif_tags = " -quiet -define tiff:ignore-tags=40965,42032,42033,42034,42036,18246,18249,36867,34864,34866 " if convert_executable then local convert_command = convert_executable .. ignore_tif_tags .. convert_arguments - dt.print_log(_("convert command is " .. convert_command)) + dt.print_log("convert command is " .. convert_command) dt.print(_("processing image stack")) local result = dtsys.external_command(convert_command) if result == 0 then @@ -580,7 +577,7 @@ local function image_stack(storage, image_table, extra_data) end else dt.print(_("ERROR: convert executable not found")) - dt.print_error(_("convert executable not found")) + dt.print_error("convert executable not found") cleanup(img_list) end job.valid = false diff --git a/contrib/image_time.lua b/contrib/image_time.lua index 17d5481..1655a12 100644 --- a/contrib/image_time.lua +++ b/contrib/image_time.lua @@ -107,7 +107,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" local ds = require "lib/dtutils.string" -local gettext = dt.gettext +local gettext = dt.gettext.gettext local img_time = {} img_time.module_installed = false @@ -125,11 +125,9 @@ script_data.restart = nil -- how to restart the (lib) script after it's been hid 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("image_time",dt.configuration.config_dir.."/lua/locale/") local function _(msgid) - return gettext.dgettext("image_time", msgid) + return gettext(msgid) end local PS = dt.configuration.runnin_os == "windows" and "\\" or "/" @@ -249,7 +247,7 @@ local function _get_windows_image_file_creation_time(image) end p:close() else - dt.print(_("unable to get information for ") .. image.filename) + dt.print(string.format(_("unable to get information for "), image.filename)) datetime = ERROR end return datetime @@ -266,7 +264,7 @@ local function _get_nix_image_file_creation_time(image) end p:close() else - dt.print(_("unable to get information for ") .. image.filename) + dt.print(string.format(_("unable to get information for "), image.filename)) datetime = ERROR end return datetime @@ -314,7 +312,7 @@ local function reset_time(images) image.exif_datetime_taken = get_original_image_time(image) end else - dt.print_error(_("reset time: no images selected")) + dt.print_error("reset time: no images selected") dt.print(_("please select the images that need their time reset")) end end @@ -430,8 +428,8 @@ end img_time.widgets = { -- name, type, tooltip, placeholder, {"ayr", "combobox", _("years"), _("years to adjust by, 0 - ?"), {seq(0,20)}, 1}, - {"amo", "combobox", _("months"), ("months to adjust by, 0-12"), {seq(0,12)}, 1}, - {"ady", "combobox", _("days"), ("days to adjust by, 0-31"), {seq(0,31)}, 1}, + {"amo", "combobox", _("months"), _("months to adjust by, 0-12"), {seq(0,12)}, 1}, + {"ady", "combobox", _("days"), _("days to adjust by, 0-31"), {seq(0,31)}, 1}, {"ahr", "combobox", _("hours"), _("hours to adjust by, 0-23"), {seq(0,23)}, 1}, {"amn", "combobox", _("minutes"), _("minutes to adjust by, 0-59"), {seq(0,59)}, 1}, {"asc", "combobox", _("seconds"), _("seconds to adjust by, 0-59"), {seq(0,59)}, 1}, diff --git a/contrib/jpg_group_leader.lua b/contrib/jpg_group_leader.lua index ab97588..e30afb8 100644 --- a/contrib/jpg_group_leader.lua +++ b/contrib/jpg_group_leader.lua @@ -73,13 +73,10 @@ script_data.show = nil -- only required for libs since the destroy_method only h -- I 1 8 N -- - - - - - - - - - - - - - - - - - - - - - - - - - -local gettext = dt.gettext - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain(MODULE, dt.configuration.config_dir .. "/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext(MODULE, msgid) + return gettext(msgid) end diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index f772fb7..0729309 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -39,7 +39,7 @@ local df = require "lib/dtutils.file" local ds = require "lib/dtutils.string" local dsys = require "lib/dtutils.system" -local gettext = dt.gettext +local gettext = dt.gettext.gettext local PS = dt.configuration.running_os == "windows" and "\\" or "/" @@ -54,11 +54,8 @@ 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("kml_export",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("kml_export", msgid) + return gettext(msgid) end local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) diff --git a/contrib/passport_guide.lua b/contrib/passport_guide.lua index 0b61728..6e10183 100644 --- a/contrib/passport_guide.lua +++ b/contrib/passport_guide.lua @@ -37,15 +37,12 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" -local gettext = dt.gettext +local gettext = dt.gettext.gettext du.check_min_api_version("2.0.0", "passport_guide") --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("passport_guide",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("passport_guide", msgid) + return gettext(msgid) end dt.guides.register_guide("passport", diff --git a/contrib/pdf_slideshow.lua b/contrib/pdf_slideshow.lua index 1194884..adffffe 100644 --- a/contrib/pdf_slideshow.lua +++ b/contrib/pdf_slideshow.lua @@ -42,17 +42,14 @@ local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" -local gettext = dt.gettext - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("pdf_slideshow",dt.configuration.config_dir.."/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext("pdf_slideshow", msgid) + return gettext(msgid) end if not df.check_if_bin_exists("pdflatex") then - dt.print_error(_("pdflatex not found")) + dt.print_error("pdflatex not found") return end @@ -231,7 +228,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"), local result = dt.control.execute(command) if result ~= 0 then dt.print(_("problem running pdflatex")) -- this one is probably usefull to the user - error(_("problem running ")..command) + error("problem running ")..command) end -- open the PDF @@ -241,7 +238,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"), local result = dt.control.execute(command) if result ~= 0 then dt.print(_("problem running pdf viewer")) -- this one is probably usefull to the user - error(_("problem running ")..command) + error("problem running "..command) end -- finally do some clean-up diff --git a/contrib/photils.lua b/contrib/photils.lua index b5e99bd..0e6662f 100644 --- a/contrib/photils.lua +++ b/contrib/photils.lua @@ -55,9 +55,7 @@ script_data.show = nil -- only required for libs since the destroy_method only h local PS = dt.configuration.running_os == "windows" and "\\" or "/" -local gettext = dt.gettext -gettext.bindtextdomain(MODULE_NAME, - dt.configuration.config_dir .. PS .. "lua" .. PS .. "locale" .. PS) +local gettext = dt.gettext.gettext local exporter = dt.new_format("jpeg") exporter.quality = 80 @@ -67,7 +65,7 @@ exporter.max_width = 224 -- helper functions local function _(msgid) - return gettext.dgettext(MODULE_NAME, msgid) + return gettext(msgid) end local function num_keys(tbl) @@ -428,7 +426,7 @@ end if not photils_installed then GUI.warning_label.label = _("photils-cli not found") - dt.print_log(_("photils-cli not found")) + dt.print_log("photils-cli not found") else GUI.warning_label.label = _("Select an image, click \"get tags\" and get \nsuggestions for tags.") end diff --git a/contrib/quicktag.lua b/contrib/quicktag.lua index 15f1d8d..82ccb53 100644 --- a/contrib/quicktag.lua +++ b/contrib/quicktag.lua @@ -62,13 +62,10 @@ qt.module_installed = false qt.event_registered = false qt.widget_table = {} -local gettext = dt.gettext - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("quicktag",dt.configuration.config_dir.."/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext("quicktag", msgid) + return gettext(msgid) end -- maximum length of button labels diff --git a/contrib/rate_group.lua b/contrib/rate_group.lua index 9a790f8..ca85b26 100644 --- a/contrib/rate_group.lua +++ b/contrib/rate_group.lua @@ -44,6 +44,12 @@ local du = require "lib/dtutils" -- added version check du.check_min_api_version("7.0.0", "rate_group") +local gettext = dt.gettext.gettext + +local function _(msgid) + return gettext(msgid) +end + -- return data structure for script_manager local script_data = {} @@ -62,9 +68,9 @@ local function apply_rating(rating) end end if rating < 0 then - dt.print("rejecting group(s)") + dt.print(_("rejecting group(s)")) else - dt.print("applying rating " ..rating.. " to group(s)") + dt.print(string.format(_("applying rating %d to group(s)"), rating)) end end @@ -81,37 +87,37 @@ end dt.register_event("rg_reject", "shortcut", function(event, shortcut) apply_rating(-1) -end, "Reject group") +end, _("Reject group")) dt.register_event("rg0", "shortcut", function(event, shortcut) apply_rating(0) -end, "Rate group 0") +end, _("Rate group 0")) dt.register_event("rg1", "shortcut", function(event, shortcut) apply_rating(1) -end, "Rate group 1") +end, _("Rate group 1")) dt.register_event("rg2", "shortcut", function(event, shortcut) apply_rating(2) -end, "Rate group 2") +end, _("Rate group 2")) dt.register_event("rg3", "shortcut", function(event, shortcut) apply_rating(3) -end, "Rate group 3") +end, _("Rate group 3")) dt.register_event("rg4", "shortcut", function(event, shortcut) apply_rating(4) -end, "Rate group 4") +end, _("Rate group 4")) dt.register_event("rg5", "shortcut", function(event, shortcut) apply_rating(5) -end, "Rate group 5") +end, _("Rate group 5")) script_data.destroy = destroy diff --git a/contrib/rename-tags.lua b/contrib/rename-tags.lua index 2213b92..4e03af7 100644 --- a/contrib/rename-tags.lua +++ b/contrib/rename-tags.lua @@ -36,6 +36,12 @@ local debug = require "darktable.debug" du.check_min_api_version("7.0.0", "rename-tags") du.deprecated("contrib/rename-tags.lua","darktable release 4.0") +local gettext = dt.gettext.gettext + +local function _(msgid) + return gettext(msgid) +end + -- return data structure for script_manager local script_data = {} @@ -50,8 +56,8 @@ rt.module_installed = false rt.event_registered = false -- GUI entries -local old_tag = darktable.new_widget("entry") { tooltip = "Enter old tag" } -local new_tag = darktable.new_widget("entry") { tooltip = "Enter new tag" } +local old_tag = darktable.new_widget("entry") { tooltip = _("Enter old tag") } +local new_tag = darktable.new_widget("entry") { tooltip = _("Enter new tag") } local function rename_reset() old_tag.text = '' @@ -62,11 +68,11 @@ end local function rename_tags() -- If entries are empty, return if old_tag.text == '' then - darktable.print ("Old tag can't be empty") + darktable.print (_("Old tag can't be empty")) return end if new_tag.text == '' then - darktable.print ("New tag can't be empty") + darktable.print (_("New tag can't be empty")) return end @@ -76,12 +82,12 @@ local function rename_tags() local ot = darktable.tags.find (old_tag.text) if not ot then - darktable.print ("Old tag does not exist") + darktable.print (_("Old tag does not exist")) return end -- Show job - local job = darktable.gui.create_job ("Renaming tag", true) + local job = darktable.gui.create_job (_("Renaming tag"), true) old_tag.editable = false new_tag.editable = false @@ -104,7 +110,7 @@ local function rename_tags() darktable.tags.delete (ot) job.valid = false - darktable.print ("Renamed tags for " .. count .. " images") + darktable.print (string.format(_("Renamed tags for %d images"), count)) old_tag.editable = true new_tag.editable = true @@ -115,7 +121,7 @@ end local function install_module() if not rt.module_installed then - darktable.register_lib ("rename_tags", "rename tag", true, true, {[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20},}, rt.rename_widget, nil, nil) + darktable.register_lib ("rename_tags", _("rename tag"), true, true, {[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20},}, rt.rename_widget, nil, nil) rt.module_installed = true end end @@ -131,13 +137,13 @@ end -- GUI local old_widget = darktable.new_widget ("box") { orientation = "horizontal", - darktable.new_widget("label") { label = "Old tag" }, + darktable.new_widget("label") { label = _("Old tag") }, old_tag } local new_widget = darktable.new_widget ("box") { orientation = "horizontal", - darktable.new_widget("label") { label = "New tag" }, + darktable.new_widget("label") { label = _("New tag") }, new_tag } @@ -146,7 +152,7 @@ rt.rename_widget = darktable.new_widget ("box") { reset_callback = rename_reset, old_widget, new_widget, - darktable.new_widget("button") { label = "Go", clicked_callback = rename_tags } + darktable.new_widget("button") { label = _("Go"), clicked_callback = rename_tags } } if darktable.gui.current_view().id == "lighttable" then diff --git a/contrib/rename_images.lua b/contrib/rename_images.lua index e8e013d..cf133cf 100644 --- a/contrib/rename_images.lua +++ b/contrib/rename_images.lua @@ -46,13 +46,10 @@ local df = require "lib/dtutils.file" du.check_min_api_version("7.0.0", "rename_images") -local gettext = dt.gettext - --- Tell gettext where to find the .mo file translating messages for a particular domain -gettext.bindtextdomain("rename_images",dt.configuration.config_dir.."/lua/locale/") +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext("rename_images", msgid) + return gettext(msgid) end -- namespace variable @@ -86,7 +83,7 @@ local MODULE_NAME = "rename_images" local PS = dt.configuration.running_os == "windows" and "\\" or "/" local USER = os.getenv("USERNAME") local HOME = os.getenv(dt.configuration.running_os == "windows" and "HOMEPATH" or "HOME") -local PICTURES = HOME .. PS .. dt.configuration.running_os == "windows" and "My Pictures" or "Pictures" +local PICTURES = HOME .. PS .. dt.configuration.running_os == "windows" and _("My Pictures") or _("Pictures") local DESKTOP = HOME .. PS .. "Desktop" -- - - - - - - - - - - - - - - - - - - - - - - - @@ -158,8 +155,8 @@ local function substitute_list(str) if rename.substitutes[var] then str = string.gsub(str, "%$%("..var.."%)", rename.substitutes[var]) else - dt.print_error(_("unrecognized variable " .. var)) - dt.print(_("unknown variable " .. var .. ", aborting...")) + dt.print_error("unrecognized variable " .. var) + dt.print(string.format(_("unknown variable %s, aborting..."), var)) return -1 end end @@ -210,7 +207,7 @@ local function do_rename(images) if #images > 0 then local pattern = rename.widgets.pattern.text dt.preferences.write(MODULE_NAME, "pattern", "string", pattern) - dt.print_log(_("pattern is " .. pattern)) + dt.print_log("pattern is " .. pattern) if string.len(pattern) > 0 then local datetime = os.date("*t") @@ -250,7 +247,7 @@ local function do_rename(images) stop_job(job) local collect_rules = dt.gui.libs.collect.filter() dt.gui.libs.collect.filter(collect_rules) - dt.print(_("renamed " .. #images .. " images")) + dt.print(string.format(_("renamed %d images"), #images)) else -- pattern length dt.print_error("no pattern supplied, returning...") dt.print(_("please enter the new name or pattern")) diff --git a/contrib/select_non_existing.lua b/contrib/select_non_existing.lua index 9baef66..9536f03 100644 --- a/contrib/select_non_existing.lua +++ b/contrib/select_non_existing.lua @@ -29,11 +29,10 @@ du.check_min_api_version("9.1.0", MODULE) -- figure out the path separator local PS = dt.configuration.running_os == "windows" and "\\" or "/" -local gettext = dt.gettext -gettext.bindtextdomain(MODULE, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS) +local gettext = dt.gettext.gettext local function _(msgid) - return gettext.dgettext(MODULE, msgid) + return gettext(msgid) end local function stop_job(job) diff --git a/contrib/select_untagged.lua b/contrib/select_untagged.lua index d15941b..bb887f2 100644 --- a/contrib/select_untagged.lua +++ b/contrib/select_untagged.lua @@ -20,7 +20,7 @@ Enable selection of untagged images (darktable|* tags are ignored) 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", "select_untagged") @@ -33,11 +33,8 @@ 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("select_untagged",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("select_untagged", msgid) + return gettext(msgid) end local function stop_job(job) diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index cf62aa6..71bae54 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -27,7 +27,7 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" -local gettext = dt.gettext +local gettext = dt.gettext.gettext du.check_min_api_version("7.0.0", "slideshowMusic") @@ -40,11 +40,8 @@ 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("slideshowMusic",dt.configuration.config_dir.."/lua/locale/") - local function _(msgid) - return gettext.dgettext("slideshowMusic", msgid) + return gettext(msgid) end local function playSlideshowMusic(_, old_view, new_view) @@ -54,7 +51,7 @@ local function playSlideshowMusic(_, old_view, new_view) playMusic = dt.preferences.read("slideshowMusic","PlaySlideshowMusic","bool") if not df.check_if_bin_exists("rhythmbox-client") then - dt.print_error(_("rhythmbox-client not found")) + dt.print_error("rhythmbox-client not found") return end @@ -70,7 +67,7 @@ local function playSlideshowMusic(_, old_view, new_view) if (old_view and old_view.id == "slideshow") then stopCommand = "rhythmbox-client --pause" --dt.print_error(stopCommand) - dt.control.execute( stopCommand) + dt.control.execute(stopCommand) end end end diff --git a/contrib/transfer_hierarchy.lua b/contrib/transfer_hierarchy.lua index 10c5f0d..15bea2a 100755 --- a/contrib/transfer_hierarchy.lua +++ b/contrib/transfer_hierarchy.lua @@ -96,10 +96,8 @@ local PATH_SEGMENT_REGEX = "(" .. PATH_SEPARATOR .. "?)([^" .. PATH_SEPARATOR .. unpack = unpack or table.unpack gmatch = string.gfind or string.gmatch -darktable.gettext.bindtextdomain(LIB_ID, darktable.configuration.config_dir .. PATH_SEPARATOR .. "lua" .. PATH_SEPARATOR .. "locale" .. PATH_SEPARATOR) - local function _(msgid) - return darktable.gettext.dgettext(LIB_ID, msgid) + return darktable.gettext.gettext(msgid) end -- Header material: END @@ -268,17 +266,17 @@ local function doTransfer(transferFunc) films[film] = destBase .. string.sub(film.path, #sourceBase+1) if not pathExists(films[film]) then if createDirectory(films[film]) == nil then - darktable.print(_("transfer hierarchy: ERROR: could not create directory: " .. films[film])) + darktable.print(string.format(_("transfer hierarchy: ERROR: could not create directory: %s"), films[film])) return end end if not pathIsDirectory(films[film]) then - darktable.print(_("transfer hierarchy: ERROR: not a directory: " .. films[film])) + darktable.print(string.format(_("transfer hierarchy: ERROR: not a directory: %s"), films[film])) return end destFilms[film] = darktable.films.new(films[film]) if destFilms[film] == nil then - darktable.print(_("transfer hierarchy: ERROR: could not create film: " .. film.path)) + darktable.print(string.format(_("transfer hierarchy: ERROR: could not create film: %s"), film.path)) end end @@ -287,7 +285,7 @@ local function doTransfer(transferFunc) srcFilms[img] = img.film end - local job = darktable.gui.create_job(string.format(_("transfer hierarchy") .. " (%d image" .. (#(darktable.gui.action_images) == 1 and "" or "s") .. ")", #(darktable.gui.action_images)), true, stopTransfer) + local job = darktable.gui.create_job(string.format(_("transfer hierarchy (%d image%s)"), #(darktable.gui.action_images), (#(darktable.gui.action_images) == 1 and "" or "s")), true, stopTransfer) job.percent = 0.0 local pctIncrement = 1.0 / #(darktable.gui.action_images) for _,img in ipairs(darktable.gui.action_images) do diff --git a/contrib/video_ffmpeg.lua b/contrib/video_ffmpeg.lua index 165b577..7c902ed 100644 --- a/contrib/video_ffmpeg.lua +++ b/contrib/video_ffmpeg.lua @@ -37,7 +37,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local df = require "lib/dtutils.file" local dsys = require "lib/dtutils.system" -local gettext = dt.gettext +local gettext = dt.gettext.gettext du.check_min_api_version("7.0.0", "video_ffmpeg") @@ -53,10 +53,9 @@ script_data.show = nil -- only required for libs since the destroy_method only h local MODULE_NAME = "video_ffmpeg" local PS = dt.configuration.running_os == "windows" and "\\" or "/" -gettext.bindtextdomain(MODULE_NAME, dt.configuration.config_dir..PS.."lua"..PS.."locale"..PS) local function _(msgid) - return gettext.dgettext(MODULE_NAME, msgid) + return gettext(msgid) end @@ -375,7 +374,7 @@ local module_widget = dt.new_widget("box") { ---- EXPORT & REGISTRATION local function show_status(enf_storage, image, format, filename, number, total, high_quality, extra_data) - dt.print(_("export ")..tostring(number).." / "..tostring(total)) + dt.print(string.format(_("export %d / %d"), number), total)) end local function init_export(storage, img_format, images, high_quality, extra_data) @@ -465,7 +464,7 @@ end dt.register_storage( "module_video_ffmpeg", - _(MODULE_NAME), + _("video ffmpeg"), show_status, finalize_export, nil,