diff --git a/join.lua b/join.lua index 6049846..031bad6 100644 --- a/join.lua +++ b/join.lua @@ -67,9 +67,9 @@ minetest.register_on_joinplayer(function(player) local codeseq = fediauth.give_code(secret_b32) local fedihandle = fediauth.storage:get_string(playername .. "_fedi"):split("@") if fediauth.is_home_instance(fedihandle[2]) then - fediauth.send_code(codeseq[1], "@" .. fedihandle[1]) + fediauth.send_code(codeseq[1], "@" .. fedihandle[1], playername) else - fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2]) + fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2], playername) end -- send verification formspec local formspec = "size[10,2]" .. @@ -148,9 +148,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local secret_b32 = fediauth.get_player_secret_b32(playername) local codeseq = fediauth.give_code(secret_b32) if fediauth.is_home_instance(fedihandle[2]) then - fediauth.send_code(codeseq[1], "@" .. fedihandle[1]) + fediauth.send_code(codeseq[1], "@" .. fedihandle[1], playername) else - fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2]) + fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2], playername) end feditempstore[playername] = fields.fediverse_account_url local formspec = "size[9,10]" .. diff --git a/locale/fediauth.ru.tr b/locale/fediauth.ru.tr new file mode 100644 index 0000000..dc67315 --- /dev/null +++ b/locale/fediauth.ru.tr @@ -0,0 +1,4 @@ +# textdomain: fediauth +This is an automated message from minetest server =Это автоматическое сообщение от minetest сервера + If you did not request this message please ignore or block. Your requested one-time code is:@n@n= Если вы не запрашивали это сообщение, пожалуйста игнорируйте или заблокируйте. Ваш запрошенный временный код:@n@n + diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..7630382 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,3 @@ +# textdomain: fediauth +This is an automated message from minetest server = + If you did not request this message please ignore or block. Your requested one-time code is:@n@n= diff --git a/mastoapi.lua b/mastoapi.lua index ccbed24..ec6eed0 100644 --- a/mastoapi.lua +++ b/mastoapi.lua @@ -1,8 +1,10 @@ local http, instance, key local server_name = minetest.settings:get("server_name") or "" local automatic_delete = minetest.settings:get_bool("fediauth.automatic_delete") +local S = minetest.get_translator("fediauth") -function fediauth.send_code(code, account_handle) +function fediauth.send_code(code, account_handle, playername) + local lang_code = minetest.get_player_information(playername).lang_code local expires_in = nil if automatic_delete then expires_in = 3600 @@ -10,8 +12,11 @@ function fediauth.send_code(code, account_handle) local status = { visibility = "direct", - status = "This is an automated message from minetest server " .. server_name .. - " If you did not request this message please ignore or block.\n\n" .. code .. "\n\n" .. account_handle, + status = minetest.get_translated_string(lang_code, S("This is an automated message from minetest server ")) .. server_name .. + minetest.get_translated_string(lang_code, S(" If you did not request this message please ignore or block. Your requested one-time code is:\n\n")) .. + code .. + "\n\n" .. + account_handle, expires_in = expires_in } local json = minetest.write_json(status) @@ -22,9 +27,9 @@ function fediauth.send_code(code, account_handle) post_data = json }, function(res) if res.code == 200 then - minetest.log("action", "[fediauth] code sent to: '" .. account_handle .. "'") + minetest.log("action", "[fediauth] code sent to: '" .. account_handle .. "' for player " .. playername) else - minetest.log("error", "[fediauth] code not sent to: '" .. account_handle .. "'") + minetest.log("error", "[fediauth] code not sent to: '" .. account_handle .. "' for player " .. playername) end end) end diff --git a/onboard.lua b/onboard.lua index d2a0ebd..b9213a9 100644 --- a/onboard.lua +++ b/onboard.lua @@ -58,9 +58,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local secret_b32 = fediauth.get_player_secret_b32(playername) local codeseq = fediauth.give_code(secret_b32) if fediauth.is_home_instance(fedihandle[2]) then - fediauth.send_code(codeseq[1], "@" .. fedihandle[1]) + fediauth.send_code(codeseq[1], "@" .. fedihandle[1], playername) else - fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2]) + fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2], playername) end feditempstore[playername] = fields.fediverse_account_url local formspec = "size[9,10]" ..