]> git.lizzy.rs Git - lmz_opening_hours.git/commitdiff
server side translation
authorIsidor Zeuner <minetest@quidecco.de>
Sat, 3 Apr 2021 22:35:32 +0000 (00:35 +0200)
committerIsidor Zeuner <minetest@quidecco.de>
Sat, 3 Apr 2021 22:35:32 +0000 (00:35 +0200)
init.lua
locale/lmz_opening_hours.de.tr
locale/template.txt

index 4918f61ffdfbef74e46c2679cd5ef2608ac33e5b..abb0e5a616af787c0f3f7f33a83c3e721711425d 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -103,6 +103,11 @@ local function load_data()
        elseif not opening_hours.version then
                opening_hours = opening_hours_default
        end
+       for k, v in pairs(opening_hours) do
+               if k ~= "exception_today" then
+                       opening_hours[k] = tonumber(v)
+               end
+       end
 end
 
 local function reset_execption()
@@ -231,6 +236,33 @@ local function show_gui(name)
                [5] = S("Fr."),
                [6] = S("Sa.")
        }
+       local player_info = minetest.get_player_information(name)
+       local warning_config_translation_string = S(
+               "@1 minutes before closing, warn the players every @2 minutes.",
+               "<warn_offset>",
+               "<warn_interval>"
+       )
+       local warning_config = minetest.get_translated_string(
+               player_info.lang_code,
+               warning_config_translation_string
+       ) .. "<"
+       local formspec_warning = ""
+       local warning_x = 0.34
+       for fragment in warning_config:gmatch("([^<>]+<?)") do
+               local label = fragment:match("<$")
+               if label then
+                       fragment = fragment:gsub("<$", "")
+               end
+               if label then
+                       formspec_warning = formspec_warning ..
+                       "label[" .. warning_x .. "," .. lab_close_y .. ";" .. fragment .. "]"
+                       warning_x = warning_x + 0.125 * fragment:len()
+               else
+                       formspec_warning = formspec_warning ..
+                       "field[" .. (warning_x + 0.2) .. "," .. fld_close_y .. ";" .. fld_sz .. ";fld_" .. fragment .. ";;" .. o[fragment] .. "]"
+                       warning_x = warning_x + 0.6
+               end
+       end
        local formspec_business_days = ""
        for day = 1, 5, 1 do
                formspec_business_days = formspec_business_days
@@ -244,7 +276,7 @@ local function show_gui(name)
        end
        local formspec_weekend = ""
        for col = 1, 2, 1 do
-               day = (5 + col) % 7
+               local day = (5 + col) % 7
                formspec_weekend = formspec_weekend
                .. "label[" .. x["day" .. col].lab .. "," .. lab_w_y .. ";" .. day_abbreviations[day] .. "]"
                .. "field[" .. x["day" .. col].fld_f_hour .. "," .. fld_w_y .. ";" .. fld_sz .. ";fld_day" .. day .. "_start_hour;" .. S("from") .. ";" .. string.format("%02d", o["day" .. day .. "_start_hour"]) .. "]"
@@ -271,11 +303,7 @@ local function show_gui(name)
        .. formspec_weekend
        .. formspec_exception
        .. "label[" .. x.day1.lab .. ",5.4833116601647;" .. S("Settings") .. "]"
-       .. "label[0.34," .. lab_close_y .. ";Spieler ]"
-       .. "field[1.6," .. fld_close_y .. ";" .. fld_sz .. ";fld_warn_offset;;" .. o.warn_offset .. "]"
-       .. "label[2.18," .. lab_close_y .. ";Minuten vor Ablauf der Zeit alle]"
-       .. "field[6.0," .. fld_close_y .. ";" .. fld_sz .. ";fld_warn_interval;;" .. o.warn_interval .. "]"
-       .. "label[6.6," .. lab_close_y .. ";Minuten warnen.]"
+       .. formspec_warning
        .. "image_button[5.14,7.6072821846554;2.605,0.7835;;save;" .. S("Save") .. "]"
        .. "image_button_exit[7.62,7.6072821846554;2.605,0.7835;;close;" .. S("Close") .. "]"
        minetest.show_formspec(name, "lmz_opening_hours:gui", formspec)
index a2353b0fe029b2ec07a206d8727f426c9b558599..aa3dab52e52abaf79bfff3a41d140c9db9a2329b 100644 (file)
@@ -23,3 +23,4 @@ The server is closing!=Der Server schließt!
 The server will close in @1 minutes.=Der Server schließt in @1 Minuten.
 Save=Speichern
 Close=Schließen
+@1 minutes before closing, warn the players every @2 minutes.=Spieler @1 Minuten vor Ablauf der Zeit alle @2 Minuten warnen.
index b4e54e77dffe049c8d63f287a5593232d9785b66..a5e1b6408966dd77b1b59d785aed7c6302a32551 100644 (file)
@@ -23,3 +23,4 @@ The server is closing!=
 The server will close in @1 minutes.=
 Save=
 Close=
+@1 minutes before closing, warn the players every @2 minutes.=