Translating mods

Post Reply
User avatar
MCL
Member
Posts: 654
Joined: Mon Aug 20, 2018 00:44
GitHub: MCLx86
IRC: migdyn
In-game: singleplayer
Contact:

Translating mods

by MCL » Post

The changelog says that mods can be now translated?
How do you do that?
2014-02-14 - 2024-02-14 TEN YEARS OF MCL

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

Re: Translating mods

by Linuxdirk » Post

You need to change how your strings are set in your mods and you need a new file in a new folder.

Code: Select all

local S = minetest.get_translator('modname')
local foo = S('My translated string')
File ./locale/modname.de.tr (syntax: textdomain.language.tr, it is advised to simply use the mod name as textdomain to avoid naming conflicts):

Code: Select all

# textdomain: modname
My translated string=Meine übersetzte Zeichenkette
You can also use variables named @1 to @9 being positional arguments.

Code: Select all

local foo = S('This is important: @1, this too: @2', super_important_variable, second_important_thing)
You can't skip a variable. In your translation file it's the same.

Code: Select all

# textdomain: modname
My translated string=Meine übersetzte Zeichenkette
This is important: @1, this too: @2=Dies ist wichtig: @1, dies auch: @2
See here for full documentation:

https://github.com/minetest/minetest/bl ... 2455-L2549

Since the system ignores empty lines and all lines not being original string=translated string or lines starting with # textdomain: you can also comment and group your translations.

https://gitlab.com/4w/mtimer/raw/4f8009 ... imer.de.tr

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests