From 842f2fca66a1c6f9121454c60d51093a2fe6b163 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Mon, 16 Sep 2024 21:16:34 -0400 Subject: [PATCH 1/2] contrib/[g-o]*.lua - clean up translatable strings --- contrib/HDRMerge.lua | 10 ++++------ contrib/LabelsToTags.lua | 8 +++----- contrib/OpenInExplorer.lua | 2 -- contrib/geoJSON_export.lua | 12 +++++------- contrib/geoToolbox.lua | 10 ++++------ contrib/gimp.lua | 2 -- contrib/gpx_export.lua | 4 +--- contrib/harmonic_armature_guide.lua | 2 -- contrib/hif_group_leader.lua | 6 ++---- contrib/hugin.lua | 6 ++---- contrib/image_stack.lua | 10 ++++------ contrib/image_time.lua | 6 ++---- contrib/jpg_group_leader.lua | 6 ++---- contrib/kml_export.lua | 8 +++----- 14 files changed, 32 insertions(+), 60 deletions(-) diff --git a/contrib/HDRMerge.lua b/contrib/HDRMerge.lua index 5ab1bee..76067d5 100644 --- a/contrib/HDRMerge.lua +++ b/contrib/HDRMerge.lua @@ -54,8 +54,6 @@ du.check_min_api_version("7.0.0", "HDRmerge") -- Tell gettext where to find the .mo file translating messages for a particular domain local gettext = dt.gettext.gettext -dt.gettext.bindtextdomain("HDRMerge", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -218,7 +216,7 @@ 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(_('HDRMerge install issue, please ensure the binary path is proper')) + dt.print(_('HDRMerge install issue, please ensure the binary path is correct')) return end images = dt.gui.selection() --get selected images @@ -416,14 +414,14 @@ GUI.Target.copy_tags = dt.new_widget('check_button'){ temp = dt.preferences.read(mod, 'active_add_tags', 'string') if temp == '' then temp = nil end GUI.Target.add_tags = dt.new_widget('entry'){ - tooltip = _('additional tags to be added on import, seperate with commas, all spaces will be removed'), + tooltip = _('additional tags to be added on import, separate with commas, all spaces will be removed'), text = temp, - placeholder = _('enter tags, seperated by commas'), + placeholder = _('enter tags, separated by commas'), editable = true } GUI.run = dt.new_widget('button'){ label = _('merge'), - tooltip =_('run HDRMerge with the above specified settings'), + tooltip =_('run HDRMerge with the above settings'), clicked_callback = function() main() end } GUI.exes.HDRMerge = dt.new_widget('file_chooser_button'){ diff --git a/contrib/LabelsToTags.lua b/contrib/LabelsToTags.lua index 1054a8b..0c00c12 100644 --- a/contrib/LabelsToTags.lua +++ b/contrib/LabelsToTags.lua @@ -54,8 +54,6 @@ du.check_min_api_version("7.0.0", "LabelsToTags") local gettext = darktable.gettext.gettext -darktable.gettext.bindtextdomain("LabelsToTags", darktable.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -216,8 +214,8 @@ ltt.my_widget = darktable.new_widget("box") { orientation = "vertical", mappingComboBox, darktable.new_widget("button") { - label = "start", - tooltip = "Tag all selected images", + label = _("start"), + tooltip = _("tag all selected images"), clicked_callback = doTagging } } @@ -247,7 +245,7 @@ end local function install_module() if not ltt.module_installed then - darktable.register_lib(LIB_ID,"labels to tags",true,true,{ + darktable.register_lib(LIB_ID,_("labels to tags"),true,true,{ [darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",20}, },ltt.my_widget,nil,nil) ltt.module_installed = true diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua index 1633a1a..4ba5969 100644 --- a/contrib/OpenInExplorer.lua +++ b/contrib/OpenInExplorer.lua @@ -56,8 +56,6 @@ local gettext = dt.gettext.gettext --Check API version du.check_min_api_version("7.0.0", "OpenInExplorer") -dt.gettext.bindtextdomain("OpenInExplorer", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index dc336b2..aff04b2 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -40,8 +40,6 @@ local gettext = dt.gettext.gettext du.check_min_api_version("7.0.0", "geoJSON_export") -dt.gettext.bindtextdomain("geoJSON_export", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -92,19 +90,19 @@ end local function create_geoJSON_file(storage, image_table, extra_data) if not df.check_if_bin_exists("mkdir") then - dt.print_error(_("mkdir not found")) + dt.print_error("mkdir not found") return end if not df.check_if_bin_exists("convert") then - dt.print_error(_("convert not found")) + dt.print_error("convert not found") return end if not df.check_if_bin_exists("xdg-open") then - dt.print_error(_("xdg-open not found")) + dt.print_error("xdg-open not found") return end if not df.check_if_bin_exists("xdg-user-dir") then - dt.print_error(_("xdg-user-dir not found")) + dt.print_error("xdg-user-dir not found") return end @@ -295,7 +293,7 @@ local function create_geoJSON_file(storage, image_table, extra_data) file:write(geoJSON_file) file:close() - dt.print("geoJSON file created in "..exportDirectory) + dt.print(string.format(_("%s file created in %s", "geoJSON", exportDirectory))) -- Open the file with the standard programm if ( dt.preferences.read("geoJSON_export","OpengeoJSONFile","bool") == true ) then diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 677af0a..f2ab695 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -33,8 +33,6 @@ local gettext = dt.gettext.gettext du.check_min_api_version("7.0.0", "geoToolbox") -dt.gettext.bindtextdomain("geoToolbox", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -77,7 +75,7 @@ local label_copy_gps_lon = dt.new_widget("check_button") } local label_copy_gps_ele = dt.new_widget("check_button") { - label = _("elevation:"), + label = _("elevation: "), value = true } -- @@ -372,12 +370,12 @@ end local function reverse_geocode() if not df.check_if_bin_exists("curl") then - dt.print_error(_("curl not found")) + dt.print_error("curl not found") return end if not df.check_if_bin_exists("jq") then - dt.print_error(_("jq not found")) + dt.print_error("jq not found") return end @@ -597,7 +595,7 @@ local function install_module() if not gT.module_installed then dt.register_lib( "geoToolbox", -- Module name - "geo toolbox", -- name + _("geo toolbox"), -- name true, -- expandable false, -- resetable {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers diff --git a/contrib/gimp.lua b/contrib/gimp.lua index 9a60cad..8e28551 100644 --- a/contrib/gimp.lua +++ b/contrib/gimp.lua @@ -74,8 +74,6 @@ local gimp_widget = nil du.check_min_api_version("7.0.0", "gimp") -dt.gettext.bindtextdomain("gimp", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end diff --git a/contrib/gpx_export.lua b/contrib/gpx_export.lua index b3d9301..84fc7bf 100644 --- a/contrib/gpx_export.lua +++ b/contrib/gpx_export.lua @@ -29,8 +29,6 @@ local gettext = dt.gettext dl.check_min_api_version("7.0.0", "gpx_export") -gettext.bindtextdomain("gpx_export", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext.dgettext("gpx_export", msgid) end @@ -150,7 +148,7 @@ local function install_module() if not gpx.module_installed then dt.register_lib( "gpx_exporter", - "gpx export", + _("gpx export"), true, -- expandable true, -- resetable {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers diff --git a/contrib/harmonic_armature_guide.lua b/contrib/harmonic_armature_guide.lua index fd16f2b..a85195c 100644 --- a/contrib/harmonic_armature_guide.lua +++ b/contrib/harmonic_armature_guide.lua @@ -36,8 +36,6 @@ local gettext = dt.gettext.gettext du.check_min_api_version("2.0.0", "harmonic_armature_guide") -dt.gettext.bindtextdomain("harmonic_armature_guide", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end diff --git a/contrib/hif_group_leader.lua b/contrib/hif_group_leader.lua index 26eaf48..2252f96 100644 --- a/contrib/hif_group_leader.lua +++ b/contrib/hif_group_leader.lua @@ -64,8 +64,6 @@ du.check_min_api_version("7.0.0", MODULE) local gettext = dt.gettext.gettext -dt.gettext.bindtextdomain("hif_group_leader", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -188,7 +186,7 @@ dt.register_event(MODULE .. "_collect", "shortcut", local images = dt.collection make_existing_hif_group_leader(images) end, - _("make hif group leader for collection") + string.format(_("make hif group leader for %s", "collection")) ) dt.register_event(MODULE .. "_select", "shortcut", @@ -196,7 +194,7 @@ dt.register_event(MODULE .. "_select", "shortcut", local images = dt.gui.selection() make_existing_hif_group_leader(images) end, - _("make hif group leader for selection") + string.format(_("make hif group leader for %s", "selection")) ) return script_data \ No newline at end of file diff --git a/contrib/hugin.lua b/contrib/hugin.lua index f209c0c..1284916 100644 --- a/contrib/hugin.lua +++ b/contrib/hugin.lua @@ -56,8 +56,6 @@ local PQ = dt.configuration.running_os == "windows" and '"' or "'" -- works with darktable API version from 5.0.0 on du.check_min_api_version("7.0.0", "hugin") -dt.gettext.bindtextdomain("hugin", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -85,7 +83,7 @@ end local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) - dt.print("exporting to hugin: "..tostring(number).."/"..tostring(total)) + dt.print(string.format(_("exporting to hugin: %d / $d", number, total))) end local function create_panorama(storage, image_table, extra_data) --finalize @@ -146,7 +144,7 @@ local function create_panorama(storage, image_table, extra_data) --finalize end if first_file == nil then - dt.print("no file selected") + dt.print(_("no file selected")) return end diff --git a/contrib/image_stack.lua b/contrib/image_stack.lua index c63ff16..817dc7a 100644 --- a/contrib/image_stack.lua +++ b/contrib/image_stack.lua @@ -73,8 +73,6 @@ local PS = dt.configuration.running_os == "windows" and "\\" or "/" -- works with LUA API version 5.0.0 du.check_min_api_version("7.0.0", "image_stack") -dt.gettext.bindtextdomain("image_stack", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -141,19 +139,19 @@ local chkbtn_will_align = dt.new_widget("check_button"){ local chkbtn_radial_distortion = dt.new_widget("check_button"){ label = _('optimize radial distortion for all images'), value = dt.preferences.read("align_image_stack", "def_radial_distortion", "bool"), - tooltip = _('optimize radial distortion for all images, \nexcept for first'), + tooltip = _('optimize radial distortion for all images, \nexcept the first'), } local chkbtn_optimize_field = dt.new_widget("check_button"){ label = _('optimize field of view for all images'), value = dt.preferences.read("align_image_stack", "def_optimize_field", "bool"), - tooltip =_('optimize field of view for all images, except for first. \nUseful for aligning focus stacks (DFF) with slightly \ndifferent magnification.'), + tooltip =_('optimize field of view for all images, except the first. \nUseful for aligning focus stacks (DFF) with slightly \ndifferent magnification.'), } local chkbtn_optimize_image_center = dt.new_widget("check_button"){ label = _('optimize image center shift for all images'), value = dt.preferences.read("align_image_stack", "def_optimize_image_center", "bool"), - tooltip =_('optimize image center shift for all images, \nexcept for first.'), + tooltip =_('optimize image center shift for all images, \nexcept the first.'), } local chkbtn_auto_crop = dt.new_widget("check_button"){ @@ -506,7 +504,7 @@ local function image_stack(storage, image_table, extra_data) return end - job = dt.gui.create_job("image stack", true, stop_job) + job = dt.gui.create_job(_("image stack"), true, stop_job) job.percent = job.percent + percent_step -- align images if requested diff --git a/contrib/image_time.lua b/contrib/image_time.lua index ff5f8c2..4daf9c6 100644 --- a/contrib/image_time.lua +++ b/contrib/image_time.lua @@ -116,8 +116,6 @@ img_time.event_registered = false du.check_min_api_version("7.0.0", "image_time") -dt.gettext.bindtextdomain("image_time", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -195,7 +193,7 @@ end local function synchronize_time(images) local sign = 1 - if img_time.sdir.value == "subtract" then + if img_time.sdir.value == _("subtract") then sign = -1 end synchronize_times(images, tonumber(img_time.diff_entry.text) * sign) @@ -511,7 +509,7 @@ img_time.stack = dt.new_widget("stack"){ dt.new_widget("box"){ orientation = "vertical", dt.new_widget("label"){label = _("set time")}, - dt.new_widget("section_label"){label = _("date: ")}, + dt.new_widget("section_label"){label = _("date:")}, img_time.sdy, img_time.smo, img_time.syr, diff --git a/contrib/jpg_group_leader.lua b/contrib/jpg_group_leader.lua index 6201b39..ef7cf91 100644 --- a/contrib/jpg_group_leader.lua +++ b/contrib/jpg_group_leader.lua @@ -64,8 +64,6 @@ du.check_min_api_version("7.0.0", MODULE) local gettext = dt.gettext.gettext -dt.gettext.bindtextdomain("jpg_group_leader", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -188,7 +186,7 @@ dt.register_event(MODULE .. "_collect", "shortcut", local images = dt.collection make_existing_jpg_group_leader(images) end, - _("make jpg group leader for collection") + string.format(_("make jpg group leader for %s", "collection")) ) dt.register_event(MODULE .. "_select", "shortcut", @@ -196,7 +194,7 @@ dt.register_event(MODULE .. "_select", "shortcut", local images = dt.gui.selection() make_existing_jpg_group_leader(images) end, - _("make jpg group leader for selection") + string.format(_("make jpg group leader for %s", "selection")) ) return script_data \ No newline at end of file diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index ec1aa04..561e8ba 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -45,8 +45,6 @@ local PS = dt.configuration.running_os == "windows" and "\\" or "/" du.check_min_api_version("7.0.0", "kml_export") -dt.gettext.bindtextdomain("kml_export", dt.configuration.config_dir .."/lua/locale/") - local function _(msgid) return gettext(msgid) end @@ -95,12 +93,12 @@ local function create_kml_file(storage, image_table, extra_data) end if not df.check_if_bin_exists(magickPath) then - dt.print_error(_("magick not found")) + dt.print_error("magick not found") return end if dt.configuration.running_os == "linux" then if not df.check_if_bin_exists("xdg-user-dir") then - dt.print_error(_("xdg-user-dir not found")) + dt.print_error("xdg-user-dir not found") return end end @@ -110,7 +108,7 @@ local function create_kml_file(storage, image_table, extra_data) if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true and dt.configuration.running_os == "linux") then if not df.check_if_bin_exists("zip") then - dt.print_error(_("zip not found")) + dt.print_error("zip not found") return end exportDirectory = dt.configuration.tmp_dir From 64840089e97547a4dd1d9490efc696b9bcd92b52 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 12 Oct 2024 20:28:01 -0400 Subject: [PATCH 2/2] clean up a few issues with parentheses and missed strings. --- contrib/geoJSON_export.lua | 2 +- contrib/hif_group_leader.lua | 4 ++-- contrib/hugin.lua | 2 +- contrib/jpg_group_leader.lua | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index aff04b2..93ecd9f 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -293,7 +293,7 @@ local function create_geoJSON_file(storage, image_table, extra_data) file:write(geoJSON_file) file:close() - dt.print(string.format(_("%s file created in %s", "geoJSON", exportDirectory))) + dt.print(string.format(_("%s file created in %s"), "geoJSON", exportDirectory)) -- Open the file with the standard programm if ( dt.preferences.read("geoJSON_export","OpengeoJSONFile","bool") == true ) then diff --git a/contrib/hif_group_leader.lua b/contrib/hif_group_leader.lua index 2252f96..9543bec 100644 --- a/contrib/hif_group_leader.lua +++ b/contrib/hif_group_leader.lua @@ -186,7 +186,7 @@ dt.register_event(MODULE .. "_collect", "shortcut", local images = dt.collection make_existing_hif_group_leader(images) end, - string.format(_("make hif group leader for %s", "collection")) + string.format(_("make hif group leader for %s", _("collection"))) ) dt.register_event(MODULE .. "_select", "shortcut", @@ -194,7 +194,7 @@ dt.register_event(MODULE .. "_select", "shortcut", local images = dt.gui.selection() make_existing_hif_group_leader(images) end, - string.format(_("make hif group leader for %s", "selection")) + string.format(_("make hif group leader for %s", _("selection"))) ) return script_data \ No newline at end of file diff --git a/contrib/hugin.lua b/contrib/hugin.lua index 1284916..4986842 100644 --- a/contrib/hugin.lua +++ b/contrib/hugin.lua @@ -83,7 +83,7 @@ end local function show_status(storage, image, format, filename, number, total, high_quality, extra_data) - dt.print(string.format(_("exporting to hugin: %d / $d", number, total))) + dt.print(string.format(_("exporting to hugin: %d / $d"), number, total)) end local function create_panorama(storage, image_table, extra_data) --finalize diff --git a/contrib/jpg_group_leader.lua b/contrib/jpg_group_leader.lua index ef7cf91..7ca1359 100644 --- a/contrib/jpg_group_leader.lua +++ b/contrib/jpg_group_leader.lua @@ -186,7 +186,7 @@ dt.register_event(MODULE .. "_collect", "shortcut", local images = dt.collection make_existing_jpg_group_leader(images) end, - string.format(_("make jpg group leader for %s", "collection")) + string.format(_("make jpg group leader for %s", _("collection"))) ) dt.register_event(MODULE .. "_select", "shortcut", @@ -194,7 +194,7 @@ dt.register_event(MODULE .. "_select", "shortcut", local images = dt.gui.selection() make_existing_jpg_group_leader(images) end, - string.format(_("make jpg group leader for %s", "selection")) + string.format(_("make jpg group leader for %s", _("selection"))) ) return script_data \ No newline at end of file