新增自动检测语言

pull/1/head
PJ568 10 months ago
parent 54c80a8865
commit 2ed9dd164c

@ -8,3 +8,4 @@ KEY_ABOUTMIT,关于 MIT 协议,About the MIT license,關於 MIT 許可證,MIT
KEY_OTHERLICENSE,开放源代码库,Open Source Library,開放源代碼庫,オープンソースライブラリ,otros licencia
KEY_LANGUANGE,语言,Language,語言,言語,Idioma
KEY_SETTING,设置,Configuration,設置,設定,Configuración
KEY_SYSLANG,自动检测,Auto,自動,自動,Automático

1 id zh en zht jp es
8 KEY_OTHERLICENSE 开放源代码库 Open Source Library 開放源代碼庫 オープンソースライブラリ otros licencia
9 KEY_LANGUANGE 语言 Language 語言 言語 Idioma
10 KEY_SETTING 设置 Configuration 設置 設定 Configuración
11 KEY_SYSLANG 自动检测 Auto 自動 自動 Automático

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -5,19 +5,22 @@ const CONFIG_PATH = "user://settings.cfg"
func _ready():
()
()
()
func (index):
if index == 0:
TranslationServer.set_locale("zh")
()
elif index == 1:
TranslationServer.set_locale("zht")
TranslationServer.set_locale("zh")
elif index == 2:
TranslationServer.set_locale("en")
TranslationServer.set_locale("zht")
elif index == 3:
TranslationServer.set_locale("jp")
TranslationServer.set_locale("en")
elif index == 4:
TranslationServer.set_locale("jp")
elif index == 5:
TranslationServer.set_locale("es")
else:
push_error("切换语言时,选项“%d”不存在!" % index)
@ -37,7 +40,7 @@ func 切换并保存(index):
((index))
func ():
func ():
var file = ConfigFile.new()
if FileAccess.file_exists(CONFIG_PATH):
var error = file.load(CONFIG_PATH)
@ -47,14 +50,28 @@ func 读取设置():
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)
()
func ():
var locale = OS.get_locale()
if locale == "zh_CN":
return (1)
elif locale == "zh_TW":
return (2)
elif locale == "en":
return (3)
elif locale == "jp":
return (4)
elif locale == "es":
return (5)
else:
return (3)
func ():
(0)
func ():
pass

@ -11,7 +11,7 @@ func _unhandled_input(event) -> void:
func _ready():
.selected = Global.()
.selected = Global.()
func _on__pressed():

@ -76,17 +76,19 @@ text_overrun_behavior = 2
[node name="语言" type="OptionButton" parent="面板/背景色/MarginContainer/色/内容按钮分隔/正文和标题分隔2"]
layout_mode = 2
theme_override_font_sizes/font_size = 48
item_count = 5
popup/item_0/text = "简体中文"
item_count = 6
popup/item_0/text = "KEY_SYSLANG"
popup/item_0/id = 0
popup/item_1/text = "繁體中文(臺灣)"
popup/item_1/text = "简体中文"
popup/item_1/id = 1
popup/item_2/text = "English"
popup/item_2/text = "繁體中文(臺灣)"
popup/item_2/id = 2
popup/item_3/text = "日本語"
popup/item_3/text = "English"
popup/item_3/id = 3
popup/item_4/text = "Español"
popup/item_4/text = "日本語"
popup/item_4/id = 4
popup/item_5/text = "Español"
popup/item_5/id = 5
[node name="返回" type="Button" parent="面板/背景色/MarginContainer/色/内容按钮分隔"]
custom_minimum_size = Vector2(175, 64)

Loading…
Cancel
Save