small localization for code message

This commit is contained in:
localhost_frssoft 2023-10-02 21:21:59 +03:00
parent 64f1f0c47c
commit 33586a6423
5 changed files with 23 additions and 11 deletions

View File

@ -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]" ..

4
locale/fediauth.ru.tr Normal file
View File

@ -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

3
locale/template.txt Normal file
View File

@ -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=

View File

@ -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

View File

@ -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]" ..