Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MT 5 game translation (tags00) #2364

Open
wants to merge 18 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@Zweihorn
Copy link
Contributor

commented May 13, 2019

This Pull Request and comprised commits are aiming to add support for the MT 5 game translation by help of the S("string") enclosure and a local S = minetest.get_translator() stub to each applicable '*.lua' file in the mods repectively.

Please note the about 400 lines of code changed in the Lua code of the existing mods by addition of a S("string") enclosure for the translation effort. This should be in compliance to both the MT 5 core lua_api.txt and the GNU gettext toolchain procedures hopefully.

The textdomain is not set intentionally as this is up to the MT developers, I presume.

It is intended to be used in the following way, so that it avoids verbose
repetitions of minetest.translate:

  local S = minetest.get_translator(textdomain)
  S(str, ...)

As an extra commodity, if textdomain is nil, it is assumed to be "" instead.

The code was briefly tested in a MT 5.0.1 client on macOS. This is my first GitHub branch commit ever and please accept my apologies for any inconvienance in advance.

N.B. My family and me are enjoying the results of your coding efforts at home for a long time now.

I would like to thank all of the MT developers and certainly @kaeza for 'intllib' which gave me the idea and the motivation for this contribution.

[snoopy (Zweihorn)] 2019-05-13

@Zweihorn

This comment has been minimized.

Copy link
Contributor Author

commented May 13, 2019

All checks failed. 1 failing check.

Hm, this is unfortunate but not unexpected. I will look how to improve...

Show resolved Hide resolved README.txt Outdated
Show resolved Hide resolved mods/dye/init.lua Outdated
Show resolved Hide resolved mods/vessels/init.lua Outdated

Zweihorn added some commits May 13, 2019

Zweihorn
Zweihorn
@Zweihorn

This comment has been minimized.

Copy link
Contributor Author

commented May 13, 2019

I am neutral if this is 0.4.10 or 5.0.1 and happy to accept.

All checks have passed. Hip hip hooray...

@Calinou - Thx for the warm welcome.

Show resolved Hide resolved mods/fireflies/init.lua Outdated
Show resolved Hide resolved mods/flowers/init.lua Outdated

Zweihorn added some commits May 18, 2019

Zweihorn
Zweihorn
@Zweihorn

This comment has been minimized.

Copy link
Contributor Author

commented May 18, 2019

THX to @SmallJoker for pointing out the pollutions.

Show resolved Hide resolved mods/fire/init.lua Outdated
Show resolved Hide resolved mods/flowers/init.lua Outdated
Show resolved Hide resolved mods/flowers/init.lua Outdated
Show resolved Hide resolved mods/map/init.lua Outdated
@Zweihorn

This comment has been minimized.

Copy link
Contributor Author

commented May 19, 2019

The code should be called depolluted. THX to both @SmallJoker and @DS-Minetest for the checks and the kind advice.

@Zweihorn

This comment has been minimized.

Copy link
Contributor Author

commented May 19, 2019

Due to a basic misunderstanding I was not aware of the 'luacheck' avalilability for Mac OS. This was rather unfortunate and led to quite a many rounds and checks online.

Only recently I installed the 'luarocks' with MacPorts and thus the 'luarocks install luachecks'. This provides to do local code checks before commits.

Please accept my apologies and I will seek to always perform a local code check with luacheck before commiting in the future. Happy hacking.

Zweihorn added some commits May 21, 2019

Zweihorn
Add function mod.get_translator to any mod with serveral lua files
M  mods/beds/beds.lua
M  mods/beds/init.lua
M  mods/carts/cart_entity.lua
M  mods/carts/init.lua
M  mods/carts/rails.lua
M  mods/creative/init.lua
M  mods/creative/inventory.lua
M  mods/default/chests.lua
M  mods/default/craftitems.lua
M  mods/default/furnace.lua
M  mods/default/init.lua
M  mods/default/nodes.lua
M  mods/default/tools.lua
M  mods/default/torch.lua
M  mods/default/trees.lua
M  mods/farming/api.lua
M  mods/farming/hoes.lua
M  mods/farming/init.lua
M  mods/farming/nodes.lua
Zweihorn
@Zweihorn

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

(1) Add function mod.get_translator to any mod with serveral lua files.

Presumably, setting the textdomain is a task to the developers as mentioned in the top comment. This task could be helped and more easily accomplished when required once per mod only. The main lua file 'init.lua' should load the minetest.get_translator() and any sub-ordinated lua file should reuse the then defined mod.get_translator subsequently.

Example by 'beds' mod:

(a) main lua file: mods/beds/init.lua

-- Load support for MT game translation.
local S = minetest.get_translator()
. . . 
beds = { }
beds.get_translator = S

(b) sub-ordinated lua file: mods/beds/beds.lua

-- support for MT game translation.
local S = beds.get_translator

This may be understood as redundant if there is solely the 'init.lua' file in a mod respectively.

(2) Local luacheck and brief run test with MT client

  • Total: 0 warnings / 0 errors in 59 files
  • No apparent issues after loading into a MT 5.0.1 client

Hope this helps.

Zweihorn added some commits May 22, 2019

Zweihorn
Add some more translation tags (overlooked or difficult)
M  mods/default/craftitems.lua
M  mods/default/nodes.lua
M  mods/doors/init.lua
Zweihorn
Depollute the code - 06 - Undo unrelated changes due to failed repair.
M  mods/flowers/init.lua

My related review message was:
I am utterly sorry but appears as if I mixed lines 224-230 with lines 239-245 instead of an appropriate depollute. Please clarify.
Zweihorn
Zweihorn
Remove redundant commentary lines
M  mods/default/craftitems.lua
@Zweihorn

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Please note and consider my current position:

Log functions like minetest.log are aimed at providing information on technical issues and any respective strings should not be tramslated to avoid disambiguations. A translated log message may lead to confusion between users and developers if copied into problem reports to an international project team like MT devs.

Excerpt from vessels/init.lua lines 75-77 as an example:

on_metadata_inventory_take = function(pos, listname, index, stack, player)
	minetest.log("action", player:get_player_name() ..
		" takes stuff from vessels shelf at ".. minetest.pos_to_string(pos))

Hope this helps and could find a consent. Any advice welcome.

@Zweihorn Zweihorn changed the title Add support for MT 5 game translation Add support for MT 5 game translation (tags00) May 28, 2019

@Zweihorn

This comment has been minimized.

Copy link
Contributor Author

commented May 28, 2019

Resolved and continued by #2368 Pull Request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.