From 6963cab2af59aaae34479395ce329f741c7c54af Mon Sep 17 00:00:00 2001 From: 2ndbeam <166764593+2ndbeam@users.noreply.github.com> Date: Sun, 19 May 2024 13:44:40 +0300 Subject: [PATCH] Added translations --- project.godot | 4 ++ scenes/Ships/player_ship.tscn | 42 +++++++++++-------- scenes/Star System/star_system_template.tscn | 6 +-- translations/gui.csv | 10 +++++ translations/gui.csv.import | 17 ++++++++ translations/gui.en.translation | Bin 0 -> 750 bytes translations/gui.ru.translation | Bin 0 -> 905 bytes 7 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 translations/gui.csv create mode 100644 translations/gui.csv.import create mode 100644 translations/gui.en.translation create mode 100644 translations/gui.ru.translation 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 0000000000000000000000000000000000000000..a1417ee38cb9a6226cb80a9a9970695d8c06acbd GIT binary patch literal 750 zcma))ze^lJ6vxN-JD0>Cpau!&9gzcnoaZ43t~No06b9kch$1ZG`n((6+m)TMP;0F% z6&n$&6d{$3X#;1GE~&LM7Lxo0r{8z(f=C1(e0cM|^JZt>dz+iijf>D~;9r1R&<3W~ zjVh`wTAm4{r(J23??Jw|YPgfx!Eb7BqBqi>;~S9l76hdIjldz>^&RQj#<#UY9*H*( z_dHo7(FmnTTFX3XQIDW0*Ay)AnJ^G#uv7k!PG4r$ZmTRYDK!O&36Fw2HgY~sSX&~yx{w)pbksc;@<=)*;yR-rA&_Wah z6_@JfBG)#jA+_nMgYbKUb5|Y2QE<`k@A3{pQRstDe((4F{d@V5RPI)83Udy^?gv9) z9Nd|WyoUEs-k%N~U)7z+3w+4^a{y*->UV9YI6RhXd$GevIs-zff;e=gT@PHRZbyNw zT{`5nAvCfDDc2&QZBcfWIWezSNT`e_62 z