Files
godot-demo-projects/gui/translation/translation_demo.tscn
Voylin a8d797cd46 Added run-time translation example
Fixes #647
I added an example of how you can handle translations on runtime.
Small fix
2022-04-03 19:08:44 +09:00

123 lines
3.5 KiB
Plaintext

[gd_scene load_steps=6 format=3 uid="uid://7bhrbgdbrped"]
[ext_resource type="Script" path="res://translation_demo.gd" id="1"]
[ext_resource type="Font" path="res://font/droid_sans.tres" id="2_fnagj"]
[ext_resource type="Texture2D" uid="uid://bbdxdamxifokx" path="res://speaker.png" id="3"]
[ext_resource type="Texture2D" uid="uid://cxbco5txqcf40" path="res://flag_uk.png" id="4"]
[ext_resource type="AudioStream" uid="uid://d3e12qtu6rlb6" path="res://hello_en.wav" id="5"]
[node name="TranslationDemo" type="Control"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -512.0
offset_top = -300.0
offset_right = 512.0
offset_bottom = 300.0
size_flags_horizontal = 2
size_flags_vertical = 2
script = ExtResource( "1" )
[node name="English" type="Button" parent="."]
offset_left = 32.0
offset_top = 64.0
offset_right = 192.0
offset_bottom = 88.0
size_flags_horizontal = 2
size_flags_vertical = 2
text = "Use English"
[node name="Spanish" type="Button" parent="."]
offset_left = 32.0
offset_top = 112.0
offset_right = 192.0
offset_bottom = 136.0
size_flags_horizontal = 2
size_flags_vertical = 2
text = "Use Spanish"
[node name="Japanese" type="Button" parent="."]
offset_left = 32.0
offset_top = 160.0
offset_right = 192.0
offset_bottom = 184.0
size_flags_horizontal = 2
size_flags_vertical = 2
text = "Use Japanese"
[node name="Description" type="Label" parent="."]
offset_left = 243.0
offset_top = 42.0
offset_right = 804.0
offset_bottom = 312.0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "This is a demo of how a game can be internationalized.
Translations are created in a CSV file and then imported into Godot.
Using a TTF/OTF font with CJK is required for this demo to run. One is provided
in the font/ folder that you can use for your games.
Godot allows internationalized text to change automatically when the locale is
modified. Resources can also be set internationalized alternatives and replaced
automatically on locale change."
[node name="HSeparator" type="HSeparator" parent="."]
offset_left = 33.0
offset_top = 330.0
offset_right = 1001.0
offset_bottom = 370.0
[node name="HelloText" type="Label" parent="."]
offset_left = 246.0
offset_top = 381.0
offset_right = 324.0
offset_bottom = 400.0
size_flags_vertical = 0
theme_override_fonts/font = ExtResource( "2_fnagj" )
text = "KEY_HELLO"
[node name="PlayAudio" type="Button" parent="."]
offset_left = 243.0
offset_top = 442.0
offset_right = 475.0
offset_bottom = 467.0
theme_override_fonts/font = ExtResource( "2_fnagj" )
text = "KEY_PUSH"
icon = ExtResource( "3" )
[node name="Flag" type="TextureRect" parent="."]
offset_left = 85.0
offset_top = 382.0
offset_right = 213.0
offset_bottom = 467.0
texture = ExtResource( "4" )
[node name="Audio" type="AudioStreamPlayer" parent="."]
stream = ExtResource( "5" )
[node name="TextLabel" type="Label" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = 21.0
offset_top = 80.0
offset_right = 487.0
offset_bottom = 255.0
grow_horizontal = 2
grow_vertical = 2
theme_override_fonts/font = ExtResource( "2_fnagj" )
text = "This text is being translated through script:
"
__meta__ = {
"_edit_layout_mode": 1,
"_edit_use_custom_anchors": false
}
[connection signal="pressed" from="English" to="." method="_on_english_pressed"]
[connection signal="pressed" from="Spanish" to="." method="_on_spanish_pressed"]
[connection signal="pressed" from="Japanese" to="." method="_on_japanese_pressed"]
[connection signal="pressed" from="PlayAudio" to="." method="_on_play_pressed"]