Localization code + Russian localization
This commit is contained in:
parent
d14bc6359e
commit
5950f7f5bf
9 changed files with 133 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue