Localization code + Russian localization

This commit is contained in:
Евгений Титаренко 2024-01-29 21:02:33 +03:00
parent d14bc6359e
commit 5950f7f5bf
9 changed files with 133 additions and 1 deletions

BIN
locales/en.mo Normal file

Binary file not shown.

36
locales/en.po Normal file
View file

@ -0,0 +1,36 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.2\n"
msgid "Press Start or Enter"
msgstr "Press Start or Enter"
msgid "by Tea Sanctuary, 2023"
msgstr "by Tea Sanctuary, 2023"
msgid "CONGRATULATIONS!"
msgstr "CONGRATULATIONS!"
msgid ""
"It took you\n"
"{0} attempts\n"
"and {1}\n"
"to finish the game."
msgstr ""
"It took you\n"
"{0} attempts\n"
"and {1}\n"
"to finish the game."
msgid "Thank you for playing! :)"
msgstr "Thank you for playing! :)"

BIN
locales/ru.mo Normal file

Binary file not shown.

37
locales/ru.po Normal file
View file

@ -0,0 +1,37 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
"X-Generator: Poedit 3.4.2\n"
msgid "Press Start or Enter"
msgstr "Нажмите Start или Enter"
msgid "by Tea Sanctuary, 2023"
msgstr "разработчик: Tea Sanctuary, 2023"
msgid "CONGRATULATIONS!"
msgstr "ПОЗДРАВЛЯЕМ!"
msgid ""
"It took you\n"
"{0} attempts\n"
"and {1}\n"
"to finish the game."
msgstr ""
"Вам потребовалось\n"
"{0} попыток\n"
"и {1}\n"
"чтобы пройти игру."
msgid "Thank you for playing! :)"
msgstr "Спасибо за игру! :)"

17
locales/template.pot Normal file
View file

@ -0,0 +1,17 @@
msgid ""
msgstr ""
msgid "Press Start or Enter"
msgstr ""
msgid "by Tea Sanctuary, 2023"
msgstr ""
msgid "CONGRATULATIONS!"
msgstr ""
msgid "It took you\n{0} attempts\nand {1}\nto finish the game."
msgstr ""
msgid "Thank you for playing! :)"
msgstr ""

View file

@ -71,6 +71,15 @@ ui_confirm={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_change_language={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"echo":false,"script":null)
]
}
[internationalization]
locale/translations=PackedStringArray("res://locales/en.po", "res://locales/ru.po")
[layer_names]

View file

@ -281,6 +281,22 @@ text = "Press Start or Enter"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Label2" type="Label" parent="CanvasLayer"]
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -18.0
offset_bottom = 8.00002
grow_horizontal = 2
grow_vertical = 0
rotation = -0.001216
auto_translate = false
theme = ExtResource("3_d3ur4")
text = "Press L to change language"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Flash" type="TextureRect" parent="CanvasLayer"]
clip_children = 2
material = SubResource("ShaderMaterial_eqq24")

View file

@ -1,13 +1,21 @@
using System.Collections.Generic;
using Godot;
using Godot.Collections;
public partial class Menu : Node2D
{
private Timer _timer;
private AudioStreamPlayer2D _thunderclap;
private AnimationPlayer _animationPlayer;
private Array<string> _translations = new Array<string>{"en", "ru"};
private int _languagesCount;
private int _currentLanguage = 0;
public override void _Ready()
{
TranslationServer.SetLocale("en");
_languagesCount = _translations.Count;
_timer = (Timer)FindChild("Timer");
_thunderclap = (AudioStreamPlayer2D)FindChild("Thunderclap");
_animationPlayer = (AnimationPlayer)FindChild("AnimationPlayer");
@ -24,6 +32,13 @@ public partial class Menu : Node2D
_thunderclap.Play();
_timer.Start();
}
else if (@event.IsActionPressed("ui_change_language"))
{
_currentLanguage++;
if (_currentLanguage >= _languagesCount)
_currentLanguage = 0;
TranslationServer.SetLocale(_translations[_currentLanguage]);
}
}
public void ChangeScene()

View file

@ -16,7 +16,9 @@ public partial class WinScreen : TextureRect
Visible = true;
TextLabel.Text =
$"It took you\n{Manager.GetAttempts()} attempts\nand {Manager.GetFormattedTimeElapsed()}\nto finish the game.";
string.Format(Tr("It took you\n{0} attempts\nand {1}\nto finish the game."),
Manager.GetAttempts(),
Manager.GetFormattedTimeElapsed());
}
public override void _Input(InputEvent @event)