examples/*.lua - cleaned up translatable messages

This commit is contained in:
Bill Ferguson
2024-09-10 21:19:37 -04:00
parent abdfc9de0b
commit ce7ddfa472
12 changed files with 46 additions and 68 deletions

View File

@@ -27,8 +27,6 @@ local dt = require "darktable"
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("api_version", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
@@ -41,7 +39,7 @@ end
local result = dt.configuration.api_version_string
dt.print_log("API Version: " .. result)
dt.print(string.format(_("API version: %s"), result))
dt.print("API " .. _("version") .. ": " .. result)
-- set the destroy routine so that script_manager can call it when
-- it's time to destroy the script and then return the data to

View File

@@ -60,8 +60,6 @@ local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("darkroom_demo", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
@@ -93,7 +91,7 @@ dt.gui.current_view(dt.gui.views.darkroom)
local max_images = 10
dt.print(_("showing images, with a pause in between each"))
dt.print(_("showing images, with a pause between each"))
sleep(1500)
-- display first 10 images of collection pausing for a second between each

View File

@@ -69,8 +69,6 @@ dt.print_error("Hello World!")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("gettextExample", dt.configuration.config_dir .."/lua/locale/")
-- Translate a string using the darktable textdomain
dt.print_error(gettext("image"))

View File

@@ -5,7 +5,6 @@ local NaN = 0/0
local wg = {}
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("gui_action", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
@@ -29,37 +28,37 @@ script_data.show = nil -- only required for libs since the destroy_method only h
wg.action = dt.new_widget("entry"){
text = "lib/filter/view",
placeholder = "action path",
tooltip = "enter the full path of an action, for example 'lib/filter/view'"
placeholder = _("action path"),
tooltip = _("enter the full path of an action, for example 'lib/filter/view'")
}
wg.instance = dt.new_widget("combobox"){
label = "instance",
tooltip = "the instance of an image processing module to execute action on",
label = _("instance"),
tooltip = _("the instance of an image processing module to execute action on"),
"0", "+1", "-1", "+2", "-2", "+3", "-3", "+4", "-4", "+5", "-5", "+6", "-6", "+7", "-7", "+8", "-8", "+9", "-9"
}
wg.element = dt.new_widget("entry"){
text = "",
placeholder = "action element",
tooltip = "enter the element of an action, for example 'selection', or leave empty for default"
placeholder = _("action element"),
tooltip = _("enter the element of an action, for example 'selection', or leave empty for default")
}
wg.effect = dt.new_widget("entry"){
text = "next",
placeholder = "action effect",
tooltip = "enter the effect of an action, for example 'next', or leave empty for default"
placeholder = _("action effect"),
tooltip = _("enter the effect of an action, for example 'next', or leave empty for default")
}
wg.speed = dt.new_widget("entry"){
text = "1",
placeholder = "action speed",
tooltip = "enter the speed to use in action execution, or leave empty to only read state"
placeholder = _("action speed"),
tooltip = _("enter the speed to use in action execution, or leave empty to only read state")
}
wg.check = dt.new_widget("check_button"){
label = 'perform action',
tooltip = 'perform action or only read return',
label = _('perform action'),
tooltip = _('perform action or only read return'),
clicked_callback = function()
wg.speed.sensitive = wg.check.value
end,
@@ -73,7 +72,7 @@ wg.return_value = dt.new_widget("entry"){
dt.register_lib(
"execute_action", -- Module name
"execute gui actions", -- name
_("execute gui actions"), -- name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100},
@@ -85,33 +84,33 @@ dt.register_lib(
dt.new_widget("box")
{
orientation = "horizontal",
dt.new_widget("label"){label = "action path", halign = "start"},
dt.new_widget("label"){label = _("action path"), halign = "start"},
wg.action
},
wg.instance,
dt.new_widget("box")
{
orientation = "horizontal",
dt.new_widget("label"){label = "element", halign = "start"},
dt.new_widget("label"){label = _("element"), halign = "start"},
wg.element
},
dt.new_widget("box")
{
orientation = "horizontal",
dt.new_widget("label"){label = "effect", halign = "start"},
dt.new_widget("label"){label = _("effect"), halign = "start"},
wg.effect
},
wg.check,
dt.new_widget("box")
{
orientation = "horizontal",
dt.new_widget("label"){label = "speed", halign = "start"},
dt.new_widget("label"){label = _("speed"), halign = "start"},
wg.speed
},
dt.new_widget("button")
{
label = "execute action",
tooltip = "execute the action specified in the fields above",
label = _("execute action"),
tooltip = _("execute the action specified in the fields above"),
clicked_callback = function(_)
local sp = NaN
if wg.check.value then sp = wg.speed.text end

View File

@@ -35,8 +35,6 @@ du.check_min_api_version("2.0.0", "hello_world")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("hello_world", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end

View File

@@ -38,8 +38,6 @@ du.check_min_api_version("7.0.0", "moduleExample")
-- https://www.darktable.org/lua-api/index.html#darktable_gettext
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("moduleExample", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
@@ -87,7 +85,7 @@ local function install_module()
orientation = "vertical",
dt.new_widget("button")
{
label = _("my button"),
label = _("my ") .. "button",
clicked_callback = function (_)
dt.print(_("button clicked"))
end
@@ -112,10 +110,10 @@ local function restart()
end
-- https://www.darktable.org/lua-api/types_lua_check_button.html
local check_button = dt.new_widget("check_button"){label = _("my check_button"), value = true}
local check_button = dt.new_widget("check_button"){label = _("my ") .. "check_button", value = true}
-- https://www.darktable.org/lua-api/types_lua_combobox.html
local combobox = dt.new_widget("combobox"){label = _("my combobox"), value = 2, "8", "16", "32"}
local combobox = dt.new_widget("combobox"){label = _("my ") .. "combobox", value = 2, "8", "16", "32"}
-- https://www.darktable.org/lua-api/types_lua_entry.html
local entry = dt.new_widget("entry")
@@ -131,14 +129,14 @@ local entry = dt.new_widget("entry")
-- https://www.darktable.org/lua-api/types_lua_file_chooser_button.html
local file_chooser_button = dt.new_widget("file_chooser_button")
{
title = _("my file_chooser_button"), -- The title of the window when choosing a file
title = _("my ") .. "file_chooser_button", -- The title of the window when choosing a file
value = "", -- The currently selected file
is_directory = false -- True if the file chooser button only allows directories to be selecte
}
-- https://www.darktable.org/lua-api/types_lua_label.html
local label = dt.new_widget("label")
label.label = _("my label") -- This is an alternative way to the "{}" syntax to set a property
label.label = _("my ") .. "label" -- This is an alternative way to the "{}" syntax to set a property
-- https://www.darktable.org/lua-api/types_lua_separator.html
local separator = dt.new_widget("separator"){}
@@ -146,7 +144,7 @@ local separator = dt.new_widget("separator"){}
-- https://www.darktable.org/lua-api/types_lua_slider.html
local slider = dt.new_widget("slider")
{
label = _("my slider"),
label = _("my ") .. "slider",
soft_min = 10, -- The soft minimum value for the slider, the slider can't go beyond this point
soft_max = 100, -- The soft maximum value for the slider, the slider can't go beyond this point
hard_min = 0, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point

View File

@@ -72,8 +72,6 @@ local dtsys = require "lib/dtutils.system" -- system utilities
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("multi_os", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
@@ -215,7 +213,7 @@ end
if dt.configuration.running_os ~= "linux" then
local executable = "ufraw-batch"
local ufraw_batch_path_widget = dt.new_widget("file_chooser_button"){
title = _("select ufraw-batch[.exe] executable"),
title = string.format(_("select %s executable"), "ufraw-batch[.exe]"),
value = df.get_executable_path_preference(executable),
is_directory = false,
changed_callback = function(self)
@@ -226,7 +224,7 @@ if dt.configuration.running_os ~= "linux" then
}
dt.preferences.register("executable_paths", "ufraw-batch", -- name
"file", -- type
_('multi_os: ufraw-batch location'), -- label
'multi_os: ufraw-batch ' .. _('location'), -- label
_('installed location of ufraw-batch, requires restart to take effect.'), -- tooltip
"ufraw-batch", -- default
ufraw_batch_path_widget

View File

@@ -61,8 +61,6 @@ local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("panels_demo", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)
end
@@ -95,11 +93,11 @@ dt.gui.panel_show_all()
-- hide center_top, center_bottom, left, top, right, bottom in order
dt.print(_("hiding all panels, one at a tme"))
dt.print(_("hiding all panels, one at a time"))
sleep(1500)
for i = 1, #panels do
dt.print(_("hiding " .. panels[i]))
dt.print(string.format(_("hiding %s"), panels[i]))
dt.gui.panel_hide(panels[i])
sleep(1500)
end
@@ -110,7 +108,7 @@ end
sleep(1500)
for i = #panels, 1, -1 do
dt.print(_("showing " .. panels[i]))
dt.print(string.format(_("showing %s"), panels[i]))
dt.gui.panel_show(panels[i])
sleep(1500)
end

View File

@@ -28,8 +28,6 @@ local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("preferenceExamples", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end
@@ -49,22 +47,22 @@ du.check_min_api_version("2.0.1", "preferenceExamples")
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesString", -- name
"string", -- type
_("example string"), -- label
_("example string tooltip"), -- tooltip
_("example") .. " string", -- label
_("example") .. " string " .. _("tooltip"), -- tooltip
"String") -- default
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesBool", -- name
"bool", -- type
_("example boolean"), -- label
_("example boolean tooltip"), -- tooltip
_("example") .. " boolean", -- label
_("example") .. " boolean " .. _("tooltip"), -- tooltip
true) -- default
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesInteger", -- name
"integer", -- type
_("example integer"), -- label
_("example integer tooltip"), -- tooltip
_("example") .. " integer", -- label
_("example") .. " integer " .. _("tooltip"), -- tooltip
2, -- default
1, -- min
99) -- max
@@ -72,8 +70,8 @@ dt.preferences.register("preferenceExamples", -- script: This is a string
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesFloat", -- name
"float", -- type
_("example float"), -- label
_("example float tooltip"), -- tooltip
_("example") .. " float", -- label
_("example") .. " float " .. _("tooltip"), -- tooltip
1.3, -- default
1, -- min
99, -- max
@@ -82,22 +80,22 @@ dt.preferences.register("preferenceExamples", -- script: This is a string
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesFile", -- name
"file", -- type
_("example file"), -- label
_("example file tooltip"), -- tooltip
_("example") .. " file", -- label
_("example") .. " file " .. _("tooltip"), -- tooltip
"") -- default
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesDirectory", -- name
"directory", -- type
_("example directory"), -- label
_("example directory tooltip"), -- tooltip
_("example") .. " directory", -- label
_("example") .. " directory " .. _("tooltip"), -- tooltip
"") -- default
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesEnum", -- name
"enum", -- type
_("example enum"), -- label
_("example enum tooltip"), -- tooltip
_("example") .. " enum", -- label
_("example") .. " enum " .. _("tooltip"), -- tooltip
"Enum 1", -- default
"Enum 1", "Enum 2") -- values

View File

@@ -28,8 +28,6 @@ du.check_min_api_version("5.0.0", "printExamples")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("printExamples", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end

View File

@@ -34,8 +34,6 @@ du.check_min_api_version("5.0.0", "running_os")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("running_os", dt.configuration.config_dir .."/lua/locale/")
local function _(msg)
return gettext(msg)
end

View File

@@ -56,7 +56,6 @@ local du = require "lib/dtutils"
du.check_min_api_version("9.2.0", "x-touch")
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain("gui_action", dt.configuration.config_dir .."/lua/locale/")
local function _(msgid)
return gettext(msgid)