You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
568_Calc/Scripts/全局.gd

61 lines
1.3 KiB

11 months ago
extends Node
const CONFIG_PATH = "user://settings.cfg"
func _ready():
()
func (index):
if index == 0:
TranslationServer.set_locale("zh")
elif index == 1:
TranslationServer.set_locale("zht")
elif index == 2:
TranslationServer.set_locale("en")
elif index == 3:
TranslationServer.set_locale("jp")
elif index == 4:
TranslationServer.set_locale("es")
else:
push_error("切换语言时,选项“%d”不存在!" % index)
TranslationServer.set_locale("en")
return index
func (index):
var file = ConfigFile.new()
file.set_value("General", "Language", index)
var error = file.save(CONFIG_PATH)
if error != OK:
push_error("Failed to save config: %d" % error)
func (index):
((index))
func ():
var file = ConfigFile.new()
if FileAccess.file_exists(CONFIG_PATH):
var error = file.load(CONFIG_PATH)
if error == OK:
return (file.get_value("General", "Language", 0))
else:
push_warning("Failed to load config: %d", error)
return (0)
else:
var locale = OS.get_locale()
if locale == "zh_CN":
return (0)
elif locale == "zh_TW":
return (1)
elif locale == "en":
return (2)
elif locale == "jp":
return (3)
elif locale == "es":
return (4)