初次提交

This commit is contained in:
2026-07-20 10:56:52 +08:00
commit 7bcc0026e0
462 changed files with 50191 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
## LocaleManager — 本地化加载(Autoload: Locale
## 权威来源:architecture_design.md ADR-A1tr("KEY") + .po + TranslationServer
## 加载 translations/*.po 并注册到 TranslationServer,设默认语言。
## 商业发行至少支持 简中 / 繁中 / 英 / 日 四语(P-S6-06)。
extends Node
const LOCALES: Array = ["zh_CN", "zh_TW", "en", "ja"]
const DEFAULT_LOCALE: String = "zh_CN"
func _ready() -> void:
for loc in LOCALES:
var path: String = "res://translations/%s.po" % loc
if ResourceLoader.exists(path):
var t = load(path)
if t is Translation:
TranslationServer.add_translation(t)
TranslationServer.set_locale(DEFAULT_LOCALE)
func set_locale(loc: String) -> void:
TranslationServer.set_locale(loc)
func get_locale() -> String:
return TranslationServer.get_locale()
## 调试 / 设置菜单用:循环切换语言
func cycle_locale() -> String:
var cur: String = TranslationServer.get_locale()
var idx: int = LOCALES.find(cur)
if idx < 0:
idx = 0
var nxt: String = LOCALES[(idx + 1) % LOCALES.size()]
TranslationServer.set_locale(nxt)
return nxt