Added translations

This commit is contained in:
2ndbeam 2024-05-19 13:44:40 +03:00
commit 6963cab2af
7 changed files with 59 additions and 20 deletions

View file

@ -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"

View file

@ -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")

View file

@ -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")

10
translations/gui.csv Normal file
View file

@ -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версия закрытого бета-теста
1 en ru
2 PLAYER_GUI_MONEY Money: Деньги:
3 PLAYER_GUI_SHIELD Shield: Щит:
4 PLAYER_GUI_HEALTH Health: Здоровье:
5 PLAYER_GUI_VELOCITY Velocity: Скорость:
6 PLAYER_GUI_AMMUNITION Ammunition: Боеприпасы:
7 PLAYER_GUI_AMMUNITION_LASER Laser Energy: Заряд лазера:
8 PLAYER_GUI_AMMUNITION_ROCKETS Rockets: Ракеты:
9 GAME_VERSION_UNCOMPILED \ndebug/prerelease version\nbuild \nотладочная/предрелизная версия\nсборка
10 GAME_VERSION_BETA beta\nclosed beta version beta\nверсия закрытого бета-теста

View file

@ -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

Binary file not shown.

Binary file not shown.