Working with modules from Lua scripts in darktable

Hi, can you describe that in a bit more detail? Would you like to be able to select more module presets in the script? Should the script create new presets? What is your use case?

Hi, Iā€™m talking about the ability to store new presets to use in different scenarios.

Screenshot from 2023-04-21 12-58-03

For instance, if I want to process a bunch of images in B/W I set the color balance options unchanged, change other parameters, then, store as preset with a related name ā€œB/W baseā€. For a group of images that I prefer to use filmic rgb, store another preset, and with Sigmoid the same.

1 Like

If you save a style does this module and settings get save with itā€¦ might be a way to do it for now if it doesā€¦ I dont have time to try nowā€¦

EDIT
Looks like noā€¦

1 Like

Hi,

right now, it is not implemented to save (and later recall) the module settings as multiple presets. Your current settings are saved in darktable preferences and restored after the next start of the application. if you will, there is only one preset. I dont know, if there is a way to use the internal preset mechanism of darktable, but it should be possible to implemented with lua.

First things first: Another request was, to translate the script output to Spanish. I will look at this first.

2 Likes

Hi,

The script you have created works very well, I am using it as part of my daily workflow and so far it has given me excellent results. in fact several users of the Hispanic darktable community are interested in using it. Thank you very much for this great contribution that speeds up the development process.

Greetings from Havana, Cuba.

2 Likes

Thank you very much for your feedback!

1 Like

Hi,

I try to add a german translation to my script, with gettext and .po/.mo files. I think, I follow the documentation, but it does not work. Attached, you can find my current version.

InitialWorkflowModule.zip (365.6 KB)

I am using the following code at the beginning of the script:

local ModuleName = "InitialWorkflowModule"

function ScriptFilePath()
  local str = debug.getinfo(1, "S").source:sub(2)
  return str:match("(.*[/\\])")
end

local gettext = dt.gettext

local pathSeparator = dt.configuration.running_os == "windows" and "\\" or "/"
local localePath = ScriptFilePath() .. "locale" .. pathSeparator

gettext.bindtextdomain(ModuleName, localePath)

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

Some lines later I want to test it. The .po-file contains a translation for ā€œThe script outputs are in English.ā€, I expect ā€œDie Ausgaben des Skripts erfolgen in deutscher Ɯbersetzung.ā€, but gettext returns the default english text.

LogInfo("Script executed from " .. ScriptFilePath())
LogInfo("Script translation files in " .. localePath)
LogInfo(_("The script outputs are in English."))

image

What am I doing wrong? Is there a way to debug gettext to see, if it reads my .mo-file?

did you try the examples/gettextExample.lua script?

Yes, I think Iā€™m doing the same. I am using xgettext and msgfmt to create the .po and the .mo file. Both files have the same module name. My script calls gettext.bindtextdomain to define the locale folder for that module name.

There is one difference: I am using a different ā€œlocaleā€ folder, below the script directory. But if I use ā€œ.config/darktable/lua/locale/de_DE/LC_MESSAGES/ā€ instead to store the files and if I use the corresponding call to bindtextdomain it is the same result: It does not workā€¦

I think Iā€™m making a little ā€œinvisibleā€ mistake and I canā€™t find it :slight_smile:

Thanks for the nice script. It can really minimize numbers of ā€œstandardā€ clicks. Is it possible to apply the script to all selected images? Or is it possible to call lua scripts from darktable-cli? That would be awesome!

Best regards
Till

Yes, you can run it from Lighttable view to apply changes to multiple selected images.

Thanks a lot for your respinse, so I can have some coffee and start editing with basic parameters set afterwards! Cool!

1 Like

I tried the examples/gettextExample.lua script, but it doesnĀ“t work for me. I followed the documentation within the script. I created the .mo file and copied it to .config/darktable/lua/de_DE/LC_MESSAGES
msgfmt -v gettextExample.po -o gettextExample.mo

darktable => preferences => general => interface language = Deutsch (de)

After starting the script using the script manager it should output this three lines, but it doesnĀ“t translate the last line to ā€œHallo Welt!ā€.
LUA ERROR Hello World!
LUA ERROR Bild
LUA ERROR Hallo Welt!

Could anybody try the gettextExample script?

Iā€™ll try and test. I have to set up a VM and then set a different locale

1 Like

Does it depend on the VM/OS locale? Not only on the darktable setting?

Nevertheless, I am running EndeavourOS with German locale.

@supertobi, is translation working for you?

I would need to install additional language packs in order to do i18n. I tried just setting LANG and LOCALE, but they both went back to C since I didnā€™t have the other language packs.

what does that mean?

English

I figured it out. The translation files have to be converted from text to binary (.po files to .mo files) using msgfmt.

To get examples/gettextExample.lua to work you need to go to <your lua scripts directory>/locale/de_DE/LC_MESSAGES and run the command
msgfmt -v ../../../examples/de_DE/LC_MESSAGES/gettextExample.po -o gettextExample.mo

Then try running the script and you should see the correct output.

thats what I didā€¦