Add localization support for achievements: implement language-specific titles and update UI components

This commit is contained in:
Kirill
2026-10-18 20:32:20 +03:00
parent e1782c7b10
commit 2aced0c61a
6 changed files with 42 additions and 31 deletions
+22
View File
@@ -22,6 +22,14 @@ func node(parent: Node, child: Node, label: String) -> Node:
return child
func run() -> void:
check(load("res://stage/stage.gd") != null, "Stage integration compiles")
var scene: PackedScene = load("res://world/world.tscn")
var scene_state: SceneState = scene.get_state()
for language in ["English", "Russian"]:
var connected := false
for i in scene_state.get_connection_count():
if str(scene_state.get_connection_source(i)) == "Stage/MainMenu/Language/" + language:
connected = scene_state.get_connection_signal(i) == &"pressed" and str(scene_state.get_connection_target(i)) == "Stage/MainMenu" and scene_state.get_connection_method(i) == &"_on_change_locale_pressed" and scene_state.get_connection_binds(i) == ["en" if language == "English" else "ru"]
check(connected, language + " button connects to locale handler")
var stage := MockStage.new()
root.add_child(stage)
var world = node(stage, Control.new(), "World")
@@ -31,6 +39,7 @@ func run() -> void:
for names in [["ForcePage", "ForceHeader"], ["ResourcePage", "ResourceHeader"], ["StarPage", "StarHeader"], ["StructurePage", "StructureHeader"], ["LifePage", "LifeHeader"]]:
node(node(pages, VBoxContainer.new(), names[0]), HBoxContainer.new(), names[1])
var screen = node(stage, Control.new(), "Achievements")
var title = node(node(screen, Control.new(), "Header"), TextureRect.new(), "Title")
node(node(screen, ScrollContainer.new(), "AchievementList"), VBoxContainer.new(), "AchievementItems")
var controller = Controller.new()
controller.progress_path = "/tmp/owniverse-achievements-test-%s.cfg" % OS.get_process_id()
@@ -99,6 +108,19 @@ func run() -> void:
global.Locale = "ru"
controller.update(0.0)
check(controller.status.text.begins_with("Открыто"), "Status localizes")
check(title.texture == Controller.TITLES.ru, "Russian title selected")
check(controller.items.a71.event_label.text.contains("90 квадриллионов"), "Russian achievement text selected")
global.Locale = "en"
controller.update(0.0)
check(controller.status.text.begins_with("Unlocked"), "English status selected")
check(title.texture == Controller.TITLES.en, "English title selected")
check(controller.items.a71.event_label.text.contains("90 quadrillion"), "English achievement text selected")
controller.current = {"id": "a71", "type": "c"}
controller._display_event(controller.current)
check(controller.notification_item.event_label.text.contains("90 quadrillion"), "English notification text selected")
global.Locale = "ru"
controller.update(0.0)
check(controller.notification_item.event_label.text.contains("90 квадриллионов"), "Active notification changes language")
global.Locale = previous_locale
var path: String = controller.progress_path
stage.free()