-
-
Save Zeno-/15645da139c390994b74 to your computer and use it in GitHub Desktop.
patch 1937 rebased
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ef38fd14179b4e53a128c36a439a70b5a86d9efe Mon Sep 17 00:00:00 2001 | |
From: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com> | |
Date: Thu, 11 Dec 2014 14:27:22 +0700 | |
Subject: [PATCH] Add language setting | |
--- | |
builtin/mainmenu/tab_settings.lua | 43 +++++++++++++++++++++++++++++++++++---- | |
1 file changed, 39 insertions(+), 4 deletions(-) | |
diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua | |
index f46fd17..3f11649 100644 | |
--- a/builtin/mainmenu/tab_settings.lua | |
+++ b/builtin/mainmenu/tab_settings.lua | |
@@ -128,6 +128,32 @@ local function formspec(tabview, name, tabdata) | |
end | |
end | |
+ local language_string = "en" -- add english first because its default | |
+ local language_idx = 1 | |
+ local language_count = 1 | |
+ local language_selected = core.setting_get("language") or "en" | |
+ | |
+ local locale_path = core.get_builtin_path() .. DIR_DELIM | |
+ .. ".." .. DIR_DELIM -- go back to 'minetest' folder | |
+ .. "locale" .. DIR_DELIM -- then enter 'locale' folder | |
+ | |
+ local locale_list = core.get_dirlist(locale_path, true) | |
+ | |
+ for i=1, #locale_list, 1 do | |
+ -- check if translation file exists | |
+ if file_exists( | |
+ locale_path .. locale_list[i] .. DIR_DELIM | |
+ .. "LC_MESSAGES" | |
+ .. DIR_DELIM .. "minetest.mo" | |
+ ) then | |
+ language_string = language_string .. "," .. locale_list[i] | |
+ language_count = language_count +1 | |
+ if locale_list[i] == language_selected then | |
+ language_idx = language_count -- handle english | |
+ end | |
+ end | |
+ end | |
+ | |
local tab_string = | |
"box[0,0;3.5,4;#999999]" .. | |
@@ -156,6 +182,11 @@ local function formspec(tabview, name, tabdata) | |
.. dump(core.setting_getbool("bilinear_filter")) .. "]".. | |
"checkbox[4,1.5;cb_trilinear;".. fgettext("Tri-Linear Filtering") .. ";" | |
.. dump(core.setting_getbool("trilinear_filter")) .. "]".. | |
+ "label[4.5,2.5;" .. fgettext("Language") .. "]" .. | |
+ "dropdown[6,2.4;1.5;dd_language;" | |
+ .. language_string .. ";" .. language_idx .. "]" .. | |
+ "tooltip[dd_language;" .. | |
+ fgettext("Restart minetest for language change to take effect") .. "]" .. | |
"box[7.75,0;4,4;#999999]" .. | |
"checkbox[8,0;cb_shaders;".. fgettext("Shaders") .. ";" | |
.. dump(core.setting_getbool("enable_shaders")) .. "]" | |
@@ -177,15 +208,15 @@ local function formspec(tabview, name, tabdata) | |
if PLATFORM == "Android" then | |
tab_string = tab_string .. | |
- "box[4.25,2.75;3.25,2.15;#999999]" .. | |
- "checkbox[4.5,2.75;cb_touchscreen_target;".. fgettext("Touch free target") .. ";" | |
+ "box[4.25,3.25;3.25,2.15;#999999]" .. | |
+ "checkbox[4.5,3.2;cb_touchscreen_target;".. fgettext("Touch free target") .. ";" | |
.. dump(core.setting_getbool("touchtarget")) .. "]" | |
end | |
if core.setting_get("touchscreen_threshold") ~= nil then | |
tab_string = tab_string .. | |
- "label[4.5,3.5;" .. fgettext("Touchthreshold (px)") .. "]" .. | |
- "dropdown[4.5,4;3;dd_touchthreshold;0,10,20,30,40,50;" .. | |
+ "label[4.5,3.95;" .. fgettext("Touchthreshold (px)") .. "]" .. | |
+ "dropdown[4.5,4.45;3;dd_touchthreshold;0,10,20,30,40,50;" .. | |
((tonumber(core.setting_get("touchscreen_threshold"))/10)+1) .. "]" | |
end | |
@@ -316,6 +347,10 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) | |
core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"]) | |
ddhandled = true | |
end | |
+ if fields["dd_language"] then | |
+ core.setting_set("language",fields["dd_language"]) | |
+ ddhandled = true | |
+ end | |
if fields["dd_video_driver"] then | |
local video_driver = string.gsub(fields["dd_video_driver"], " ", "") | |
core.setting_set("video_driver",string.lower(video_driver)) | |
-- | |
1.9.3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment