diff --git a/project.godot b/project.godot index b1171b1..ac4dff3 100644 --- a/project.godot +++ b/project.godot @@ -90,6 +90,10 @@ dock={ ] } +[internationalization] + +locale/translations=PackedStringArray("res://translations/gui.en.translation", "res://translations/gui.ru.translation") + [layer_names] 2d_physics/layer_1="Ships" diff --git a/scenes/Ships/player_ship.tscn b/scenes/Ships/player_ship.tscn index 079e791..d18c6d5 100644 --- a/scenes/Ships/player_ship.tscn +++ b/scenes/Ships/player_ship.tscn @@ -15,7 +15,7 @@ resource_name = "money_counter" script/source = "extends Label ## Text with placeholder -@onready var unformatted_text: String = text +@onready var unformatted_text: String = tr(text) + \" %d\" ## Shortcut to get_parent().get_parent() @onready var ship: PlayerShip = get_parent().get_parent() @@ -28,7 +28,7 @@ resource_name = "velocity_counter" script/source = "extends Label ## Text with placeholder -@onready var unformatted_text: String = text +@onready var unformatted_text: String = tr(text) + \" %d px/s\" ## Shortcut to get_parent().get_parent() @onready var ship: PlayerShip = get_parent().get_parent() @@ -41,7 +41,7 @@ resource_name = "health_counter" script/source = "extends Label ## Text with placeholder -@onready var unformatted_text: String = text +@onready var unformatted_text: String = tr(text) + \" {0} / {1}\" ## Shortcut to get_parent().get_parent() @onready var ship: PlayerShip = get_parent().get_parent() @@ -57,7 +57,7 @@ resource_name = "shield_counter" script/source = "extends Label ## Text with placeholder -@onready var unformatted_text: String = text +@onready var unformatted_text: String = tr(text) + \" {0} / {1}\" ## Shortcut to get_parent().get_parent() @onready var ship: PlayerShip = get_parent().get_parent() @@ -73,10 +73,18 @@ resource_name = "ammunition_counter" script/source = "extends Label ## Text with placeholder -@onready var unformatted_text: String = text +@onready var unformatted_text: PackedStringArray = text.split(\"\\n\") ## Shortcut to get_parent().get_parent() @onready var ship: PlayerShip = get_parent().get_parent() +func _ready(): + for i in range(len(unformatted_text)): + unformatted_text[i] = tr(unformatted_text[i]) + unformatted_text[1] += \" {0} / {1}\" + unformatted_text[2] += \" {2} / {3}\" + for i in range(len(unformatted_text) - 1): + unformatted_text[i] += \"\\n\" + func _process(_delta): var format = [ round(ship.hull.ammunition[\"Laser Energy\"] * 100) / 100.0, @@ -84,7 +92,7 @@ func _process(_delta): ship.hull.ammunition[\"Rockets\"], ship.hull.max_ammunition[\"Rockets\"] ] - text = unformatted_text.format(format) + text = \"\".join(unformatted_text).format(format) " [node name="PlayerShip" type="Node2D"] @@ -120,7 +128,7 @@ offset_top = 611.0 offset_right = 92.0 offset_bottom = 634.0 theme = ExtResource("8_8lpnq") -text = "Money: %d" +text = "PLAYER_GUI_MONEY" script = SubResource("GDScript_ry4sc") [node name="Velocity" type="Label" parent="ColorableGUI"] @@ -129,7 +137,7 @@ offset_top = 688.0 offset_right = 137.0 offset_bottom = 711.0 theme = ExtResource("8_8lpnq") -text = "Velocity: %d px/s" +text = "PLAYER_GUI_VELOCITY" script = SubResource("GDScript_vko7a") [node name="Health" type="Label" parent="ColorableGUI"] @@ -138,7 +146,7 @@ offset_top = 663.0 offset_right = 168.0 offset_bottom = 686.0 theme = ExtResource("8_8lpnq") -text = "Health: {0} / {1} units" +text = "PLAYER_GUI_HEALTH" script = SubResource("GDScript_uoaip") [node name="Shield" type="Label" parent="ColorableGUI"] @@ -147,18 +155,18 @@ offset_top = 638.0 offset_right = 164.0 offset_bottom = 661.0 theme = ExtResource("8_8lpnq") -text = "Shield: {0} / {1} units" +text = "PLAYER_GUI_SHIELD" script = SubResource("GDScript_q1sx2") [node name="Ammunition" type="Label" parent="ColorableGUI"] -offset_left = 1060.0 -offset_top = 638.0 -offset_right = 1273.0 -offset_bottom = 713.0 +offset_left = 849.0 +offset_top = 641.0 +offset_right = 1276.0 +offset_bottom = 716.0 theme = ExtResource("8_8lpnq") -text = "Ammunition: -Laser Energy: {0} / {1} -Rockets: {2} / {3}" +text = "PLAYER_GUI_AMMUNITION +PLAYER_GUI_AMMUNITION_LASER +PLAYER_GUI_AMMUNITION_ROCKETS" horizontal_alignment = 2 script = SubResource("GDScript_rrgab") diff --git a/scenes/Star System/star_system_template.tscn b/scenes/Star System/star_system_template.tscn index 0407720..f233ecb 100644 --- a/scenes/Star System/star_system_template.tscn +++ b/scenes/Star System/star_system_template.tscn @@ -16,10 +16,10 @@ script/source = "extends Label func _ready(): text = \"cosmic {version}\".format({\"version\" : Game.gameversion}) if OS.has_feature(\"editor\"): - text += \" uncompiled\\ndebug/prerelease version\" + text += tr(\"GAME_VERSION_UNCOMPILED\") + Time.get_date_string_from_system() else: if Game.beta: - text += \" beta\\nclosed beta\" + text += tr(\"GAME_VERSION_BETA\") " [sub_resource type="GDScript" id="GDScript_r38d8"] @@ -60,7 +60,7 @@ offset_top = 6.0 offset_right = 1280.0 offset_bottom = 29.0 theme = ExtResource("5_ag247") -text = "GammaCosmicRays version Ifre 1.0" +text = "cosmic {version}" horizontal_alignment = 1 script = SubResource("GDScript_4yoh5") diff --git a/translations/gui.csv b/translations/gui.csv new file mode 100644 index 0000000..97fef72 --- /dev/null +++ b/translations/gui.csv @@ -0,0 +1,10 @@ +,en,ru +PLAYER_GUI_MONEY,Money:,Деньги: +PLAYER_GUI_SHIELD,Shield:,Щит: +PLAYER_GUI_HEALTH,Health:,Здоровье: +PLAYER_GUI_VELOCITY,Velocity:,Скорость: +PLAYER_GUI_AMMUNITION,Ammunition:,Боеприпасы: +PLAYER_GUI_AMMUNITION_LASER,Laser Energy:,Заряд лазера: +PLAYER_GUI_AMMUNITION_ROCKETS,Rockets:,Ракеты: +GAME_VERSION_UNCOMPILED,\ndebug/prerelease version\nbuild ,\nотладочная/предрелизная версия\nсборка +GAME_VERSION_BETA, beta\nclosed beta version, beta\nверсия закрытого бета-теста \ No newline at end of file diff --git a/translations/gui.csv.import b/translations/gui.csv.import new file mode 100644 index 0000000..e679125 --- /dev/null +++ b/translations/gui.csv.import @@ -0,0 +1,17 @@ +[remap] + +importer="csv_translation" +type="Translation" +uid="uid://bpjb7tesjnudy" + +[deps] + +files=["res://translations/gui.en.translation", "res://translations/gui.ru.translation"] + +source_file="res://translations/gui.csv" +dest_files=["res://translations/gui.en.translation", "res://translations/gui.ru.translation"] + +[params] + +compress=true +delimiter=0 diff --git a/translations/gui.en.translation b/translations/gui.en.translation new file mode 100644 index 0000000..a1417ee Binary files /dev/null and b/translations/gui.en.translation differ diff --git a/translations/gui.ru.translation b/translations/gui.ru.translation new file mode 100644 index 0000000..ff267cc Binary files /dev/null and b/translations/gui.ru.translation differ