Working with modules from Lua scripts in darktable

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…

What is the LANG environment variable set to? Mine was de_DE.utf8

same for me:
env: „de_DE.UTF-8“

let me try it on a “clean” VM.

I will do that on Tuesday or Wednesday.

@wpferguson : It works if I rename the locale folder “de_DE” to “de”. Same for Spanish “es_ES” and “es”.

You discussed this in another (older) thread: German script translation: charset UTF-8 deficient on Windows 10 · Issue #244 · darktable-org/lua-scripts · GitHub

For me, it is okay now. It works even outside the darktable config folder, in a separate folder below the script file (if I extend the package.path in the luarc file). It works on Arch based EndeavourOS and Windows 10 (VM).

image

The .po file is quite simple, it refers to de_DE and UTF-8 and it must be transformed to .mo as described:

Now I can start with the actual translation :slight_smile: I’ll start with the German translation, then the Spanish can follow.

2 Likes

I did rename the de_DE to de but it fails to start for me on Manjaro/Arch 4.5.0+2~g41cb1baa1d

Do you use the newest version 1.2.0 of the script, as released today?

For me, it works with Arch-based EndeavourOs, quite similar to Manjaro.

Do you get any error message, starting it with darktable -d lua?

No error messages with -d lua startup
The require is in luarc correctly
and the 1.2.0 module sits in the examples
It shows correctly in the scripts
… simply fails to load

My Error:
Now shows the folllowing:
34.4903 LUA ERROR: script_manager.lua: activate: 367: Error loading examples/InitialWorkflowModule
34.4904 LUA ERROR: script_manager.lua: activate: 368: Error message: module ‘examples/Darktable-Initial-Workflow-Module-1.2.0/InitialWorkflowModule’ not found:
no field package.preload[‘examples/Darktable-Initial-Workflow-Module-1.2.0/InitialWorkflowModule’]
no file ‘/usr/share/lua/5.4/examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule.lua’
no file ‘/usr/share/lua/5.4/examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule/init.lua’
no file ‘/usr/lib/lua/5.4/examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule.lua’
no file ‘/usr/lib/lua/5.4/examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule/init.lua’
no file ‘./examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule.lua’
no file ‘./examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule/init.lua’
no file ‘/usr/share/darktable/lua/examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule.lua’
no file ‘/home/david/.config/darktable/lua/examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule.lua’
no file ‘/usr/lib/lua/5.4/examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule.so’
no file ‘/usr/lib/lua/5.4/loadall.so’
no file ‘./examples/Darktable-Initial-Workflow-Module-1/2/0/InitialWorkflowModule.so’
no file ‘/usr/lib/lua/5.4/examples/Darktable-Initial-Workflow-Module-1.so’
no file ‘/usr/lib/lua/5.4/loadall.so’
no file ‘./examples/Darktable-Initial-Workflow-Module-1.so’