How to use client-side translations in Minetest 5.0.0?

User avatar
Linuxdirk
Member
 
Posts: 1971
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

How to use client-side translations in Minetest 5.0.0?

by Linuxdirk » Mon Jan 21, 2019 03:28

With the upcoming release client-side translations for mods finally become a thing. But how to actually use them? I tried to set up a minimal working example to play around with this, compiled the latest dev version from GitHub, and activated the mod. But the translation does not work.

Following have I done:

Set language = fr in minetest.conf just for fun. The translation of some parts of the client works like I expect it. The client is basically French now (language does not matter for my testing, I tried some of them and it’s always the same result).

Then I created a very basic mod:

init.lua

Code: Select all
local S = minetest.get_translator('testmod')
minetest.register_craftitem('testmod:test', {
    description = S('I am a test object'),
    inventory_image = 'default_stick.png^[brighten'
})

mod.conf

Code: Select all
name = testmod
depends = default

locale/testmod.fr.tr

Code: Select all
# textdomain: testmod
I am a test object=Je suis un objet de test

So basically I did what the translation-related documentation described.

But I still end up with the non-translated description.

Image

debug.txt (startup, starting world, opening inventory, hovering the item, shutting down)

Code: Select all
2019-01-21 04:19:06: [Main]: Automatically selecting world at [/home/dirk/mt5/minetest/bin/../worlds/test]
2019-01-21 04:19:07: ACTION[Main]: World at [/home/dirk/mt5/minetest/bin/../worlds/test]
2019-01-21 04:19:07: ACTION[Main]: Server for gameid="minetest" listening on 0.0.0.0:57506.
2019-01-21 04:19:07: ACTION[Server]: singleplayer [127.0.0.1] joins game.
2019-01-21 04:19:07: ACTION[Server]: singleplayer joins game. List of players: singleplayer
2019-01-21 04:19:07: WARNING[Main]: Client side scripting is disabled by client.
2019-01-21 04:19:09: WARNING[Main]: Translations: can't find translation for string "I am a test object" in textdomain "testmod"
2019-01-21 04:19:11: ACTION[Main]: Server: Shutting down

So I en d up with the translation system being properly loaded (no crash, and the original text is shown, so I assume that it basically is functional) but it seems not to find the translated string even if the language and file name, and mod name and textdomain match.

./bin/minetest --version

Code: Select all
Minetest 5.0.0-dev-df6670b (Linux)
Using Irrlicht 1.8.4
BUILD_TYPE=Release
RUN_IN_PLACE=1
USE_GETTEXT=1
USE_SOUND=1
USE_CURL=1
USE_FREETYPE=1
USE_LUAJIT=1
STATIC_SHAREDIR="."

What am I missing?
 

Nore
Developer
 
Posts: 501
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

Re: How to use client-side translations in Minetest 5.0.0?

by Nore » Mon Jan 21, 2019 10:41

You are not missing anything - the issue was the missing translation of LANG_CODE. See https://github.com/minetest/minetest/pull/8119 for details.
 

User avatar
Linuxdirk
Member
 
Posts: 1971
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk
 

kestral
Member
 
Posts: 45
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

Re: How to use client-side translations in Minetest 5.0.0?

by kestral » Fri Feb 01, 2019 21:02

Since someone wants to submit a pull request to add client-side translations to one of my mods, I thought I'd take a look at this.
Testing with my Minetest build from yesterday (Jan 31) seems to work, while the build from Jan 26 doesn't.

However, when I set language = en, or don't include a language line, Minetest spews out warning messages for every translation string it finds:

WARNING[Main]: Translations: can't find translation for string "Tunnelmaker - User Options" in textdomain "tunnelmaker"


Creating a .en.tr file doesn't make any difference.

If the intent is that all source code strings must be in English, and translating to English isn't supported, then could it be possible that this case doesn't spam the log file with so many unnecessary Translations messages?
 

Nore
Developer
 
Posts: 501
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs
 

User avatar
Linuxdirk
Member
 
Posts: 1971
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk

Re: How to use client-side translations in Minetest 5.0.0?

by Linuxdirk » Sat Feb 02, 2019 01:33

It does not work. The test mod still only triggers Translations: can't find translation for string "I am a test object" in textdomain "testmod". Version Minetest 5.0.0-dev-d521e61.

Edit: Did a completely fresh, clean build. Now not even the normal translations (client GUI) are working. It’s always English regardless of language setting in minetest.conf.
 

Nore
Developer
 
Posts: 501
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

Re: How to use client-side translations in Minetest 5.0.0?

by Nore » Sat Feb 02, 2019 08:50

If not even the client GUI is translated, then it means you did not enable gettext.
 

User avatar
Linuxdirk
Member
 
Posts: 1971
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest