Skip to content

Commit

Permalink
Merge pull request #455 from wpferguson/prep_translation
Browse files Browse the repository at this point in the history
Prepare translatable strings, step 1
  • Loading branch information
wpferguson authored May 15, 2024
2 parents ebd2cd7 + cd3788f commit ac945b9
Show file tree
Hide file tree
Showing 64 changed files with 639 additions and 642 deletions.
7 changes: 3 additions & 4 deletions contrib/AutoGrouper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ 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
gettext.bindtextdomain(MOD, dt.configuration.config_dir .."/lua/locale/")

local function _(msgid)
return gettext.dgettext("AutoGrouper", msgid)
return gettext(msgid)
end

local Ag = {}
Expand Down
31 changes: 15 additions & 16 deletions contrib/CollectHelper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,14 +62,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

gettext.bindtextdomain("CollectHelper", dt.configuration.config_dir .."/lua/locale/")

local function _(msgid)
return gettext.dgettext("CollectHelper", msgid)
return gettext(msgid)
end

-- FUNCTION --
local function CheckSingleImage(selection)
if #selection ~= 1 then
dt.print(_("Please select a single image"))
dt.print(_("please select a single image"))
return true
end
return false
Expand Down Expand Up @@ -205,47 +204,47 @@ end
dt.gui.libs.image.register_action(
"CollectHelper_prev", _("collect: previous"),
function() PreviousCollection() end,
_("Sets the Collect parameters to be the previously active parameters")
_("sets the collect parameters to be the previously active parameters")
)
if dt.preferences.read('module_CollectHelper','folder','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_folder", _("collect: folder"),
function() CollectOnFolder(_ , false) end,
_("Sets the Collect parameters to be the selected images's folder")
_("sets the collect parameters to be the selected images's folder")
)
end
if dt.preferences.read('module_CollectHelper','colors','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_labels", _("collect: color label(s)"),
function() CollectOnColors(_ , false) end,
_("Sets the Collect parameters to be the selected images's color label(s)")
_("sets the collect parameters to be the selected images's color label(s)")
)
end
if dt.preferences.read('module_CollectHelper','all_and','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_and", _("collect: all (AND)"),
function() CollectOnAll_AND() end,
_("Sets the Collect parameters based on all activated CollectHelper options")
_("sets the collect parameters based on all activated CollectHelper options")
)
end

-- PREFERENCES --
dt.preferences.register("module_CollectHelper", "all_and", -- name
"bool", -- type
_('CollectHelper: All'), -- label
_('Will create a collect parameter set that utilizes all enabled CollectHelper types (AND)'), -- tooltip
_('CollectHelper: all'), -- label
_('will create a collect parameter set that utilizes all enabled CollectHelper types (and)'), -- tooltip
true -- default
)
dt.preferences.register("module_CollectHelper", "colors", -- name
"bool", -- type
_('CollectHelper: Color Label(s)'), -- label
_('Enable the button that allows you to swap to a collection based on selected image\'s COLOR LABEL(S)'), -- tooltip
_('CollectHelper: color label(s)'), -- label
_('enable the button that allows you to swap to a collection based on selected image\'s color label(s)'), -- tooltip
true -- default
)
dt.preferences.register("module_CollectHelper", "folder", -- name
"bool", -- type
_('CollectHelper: Folder'), -- label
_('Enable the button that allows you to swap to a collection based on selected image\'s FOLDER location'), -- tooltip
_('CollectHelper: folder'), -- label
_('enable the button that allows you to swap to a collection based on selected image\'s folder location'), -- tooltip
true -- default
)

Expand Down
20 changes: 11 additions & 9 deletions contrib/HDRMerge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ 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

gettext.bindtextdomain("HDRMerge", dt.configuration.config_dir .."/lua/locale/")

local function _(msgid)
return gettext.dgettext('HDRMerge', msgid)
return gettext(msgid)
end

local temp
Expand Down Expand Up @@ -208,7 +210,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
Expand Down Expand Up @@ -277,7 +279,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

Expand Down Expand Up @@ -378,7 +380,7 @@ local lbl_import = dt.new_widget('section_label'){
}
GUI.Target.style = dt.new_widget('combobox'){
label = _('apply style on import'),
tooltip = _('Apply selected style on auto-import to newly created image'),
tooltip = _('apply selected style on auto-import to newly created image'),
selected = 1,
_('none'),
changed_callback = function(self)
Expand Down Expand Up @@ -407,9 +409,9 @@ 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, seperate with commas, all spaces will be removed'),
text = temp,
placeholder = _('Enter tags, seperated by commas'),
placeholder = _('enter tags, seperated by commas'),
editable = true
}
GUI.run = dt.new_widget('button'){
Expand All @@ -418,7 +420,7 @@ GUI.run = dt.new_widget('button'){
clicked_callback = function() main() end
}
GUI.exes.HDRMerge = dt.new_widget('file_chooser_button'){
title = _('Select HDRmerge executable'),
title = _('select HDRmerge executable'),
value = df.get_executable_path_preference(HDRM.name),
is_directory = false
}
Expand Down
52 changes: 30 additions & 22 deletions contrib/LabelsToTags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ local du = require "lib/dtutils"

du.check_min_api_version("7.0.0", "LabelsToTags")

local gettext = dt.gettext.gettext

gettext.bindtextdomain("LabelsToTags", dt.configuration.config_dir .."/lua/locale/")

local function _(msgid)
return gettext(msgid)
end

-- return data structure for script_manager

local script_data = {}
Expand All @@ -68,7 +76,7 @@ local ltt = {}
ltt.module_installed = false
ltt.event_registered = false

local LIB_ID = "LabelsToTags"
local LIB_ID = _("LabelsToTags")

-- Helper functions: BEGIN

Expand Down Expand Up @@ -109,23 +117,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 = {}
Expand All @@ -140,14 +148,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)
Expand All @@ -170,7 +178,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)

Expand Down
27 changes: 13 additions & 14 deletions contrib/OpenInExplorer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -65,19 +65,18 @@ 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/")
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
local PS = act_os == "windows" and "\\" or "/"

--Detect OS and quit if it is not supported.
if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then
dt.print(_("OpenInExplorer plug-in only supports Linux, macOS, and Windows at this time"))
dt.print(_("OpenInExplorer plug-in only supports linux, macos, and windows at this time"))
dt.print_error("OpenInExplorer plug-in only supports Linux, macOS, and Windows at this time")
return
end
Expand All @@ -93,11 +92,11 @@ local function check_if_links_dir_exists()
local dir_exists = true
if not links_dir then
--Just for paranoic reasons. I tried, but I couldn't devise a setting for a nil value.
dt.print(_("No links directory selected.\nPlease check the dt preferences (lua options)"))
dt.print(_("no links directory selected\nplease check the dt preferences (lua options)"))
dt.print_error("OpenInExplorer: No links directory selected")
dir_exists = false
elseif not df.check_if_file_exists(links_dir) then
dt.print(string.format(_("Links directory '%s' not found.\nPlease check the dt preferences (lua options)"), links_dir))
dt.print(string.format(_("links directory '%s' not found\nplease check the dt preferences (lua options)"), links_dir))
dt.print_error(string.format("OpenInExplorer: Links directory '%s' not found", links_dir))
dir_exists = false
end
Expand Down Expand Up @@ -154,7 +153,7 @@ local function set_links(selected_images)
end
]]
if dsys.external_command(run_cmd) ~= 0 then
dt.print(_("Failed to create links. Missing rights?"))
dt.print(_("failed to create links, missing rights?"))
dt.print_error("OpenInExplorer: Failed to create links")
return
end
Expand All @@ -170,13 +169,13 @@ end
local function open_in_fmanager()
local images = dt.gui.selection()
if #images == 0 then
dt.print(_("Please select an image"))
dt.print(_("please select an image"))
else
if use_links and not check_if_links_dir_exists() then
return
end
if #images > 15 and not use_links then
dt.print(_("Please select fewer images (max. 15)"))
dt.print(_("please select fewer images (max. 15)"))
elseif use_links then
set_links(images)
else
Expand All @@ -203,25 +202,25 @@ end
dt.gui.libs.image.register_action(
"OpenInExplorer", _("show in file explorer"),
function() open_in_fmanager() end,
_("Open the file manager at the selected image's location")
_("open the file manager at the selected image's location")
)


if act_os ~= "windows" then
dt.preferences.register("OpenInExplorer", "linked_image_files_dir", -- name
"directory", -- type
_("OpenInExplorer: linked files directory"), -- label
_("Directory to store the links to the file names. Requires restart to take effect"), -- tooltip
_("directory to store the links to the file names, requires restart to take effect"), -- tooltip
"Links to image files", -- default
dt.new_widget("file_chooser_button"){
title = _("Select directory"),
title = _("select directory"),
is_directory = true,
}
)
dt.preferences.register("OpenInExplorer", "use_links", -- name
"bool", -- type
_("OpenInExplorer: use links"), -- label
_("Use links instead of multiple windows. Requires restart to take effect"), -- tooltip
_("use links instead of multiple windows, requires restart to take effect"), -- tooltip
false, -- default
""
)
Expand Down
10 changes: 6 additions & 4 deletions contrib/RL_out_sharp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ 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

gettext.bindtextdomain("RL_out_sharp", dt.configuration.config_dir .."/lua/locale/")

local function _(msgid)
return gettext.dgettext(MODULE_NAME, msgid)
return gettext(msgid)
end

-- initialize module preferences
Expand Down Expand Up @@ -137,7 +139,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)
Expand Down
Loading

0 comments on commit ac945b9

Please sign in to comment.