Skip to content

Update translation demo project to include changes from GSoC 2020 i18n #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
21 changes: 21 additions & 0 deletions gui/translation/Audio/hello_en.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/hello_en.wav-383ebf8063db95d8d582a92eed30c0c7.sample"

[deps]

source_file="res://Audio/hello_en.wav"
dest_files=[ "res://.import/hello_en.wav-383ebf8063db95d8d582a92eed30c0c7.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0
File renamed without changes.
21 changes: 21 additions & 0 deletions gui/translation/Audio/hello_es.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/hello_es.wav-2d90075d2f3209df2412fb6f17bc2cad.sample"

[deps]

source_file="res://Audio/hello_es.wav"
dest_files=[ "res://.import/hello_es.wav-2d90075d2f3209df2412fb6f17bc2cad.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0
File renamed without changes.
21 changes: 21 additions & 0 deletions gui/translation/Audio/hello_jp.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/hello_jp.wav-8d7362e27f181d8a936838f55027cc98.sample"

[deps]

source_file="res://Audio/hello_jp.wav"
dest_files=[ "res://.import/hello_jp.wav-8d7362e27f181d8a936838f55027cc98.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0
Binary file added gui/translation/Audio/hello_ru.wav
Binary file not shown.
21 changes: 21 additions & 0 deletions gui/translation/Audio/hello_ru.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/hello_ru.wav-9ed07b9c8ac41a662cdd556c54dfa569.sample"

[deps]

source_file="res://Audio/hello_ru.wav"
dest_files=[ "res://.import/hello_ru.wav-9ed07b9c8ac41a662cdd556c54dfa569.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0
File renamed without changes.
23 changes: 23 additions & 0 deletions gui/translation/Fonts/droid_sans.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[gd_resource type="DynamicFont" load_steps=7 format=2]

[ext_resource path="res://Fonts/DroidSansArabic.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://Fonts/DroidSansFallback.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://Fonts/DroidSansHebrew.ttf" type="DynamicFontData" id=3]
[ext_resource path="res://Fonts/DroidSansJapanese.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://Fonts/DroidSansThai.ttf" type="DynamicFontData" id=5]
[ext_resource path="res://Fonts/DroidSans.ttf" type="DynamicFontData" id=6]


[resource]

size = 16
use_mipmaps = false
use_filter = false
font_data = ExtResource( 6 )
fallback/0 = ExtResource( 1 )
fallback/1 = ExtResource( 2 )
fallback/2 = ExtResource( 3 )
fallback/3 = ExtResource( 4 )
fallback/4 = ExtResource( 5 )
_sections_unfolded = [ "Font", "Font/fallback" ]

Binary file added gui/translation/Images/flag_japan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions gui/translation/Images/flag_japan.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture2D"
path="res://.import/flag_japan.png-c592397591720d06179b5f17d55e57ba.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Images/flag_japan.png"
dest_files=[ "res://.import/flag_japan.png-c592397591720d06179b5f17d55e57ba.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/invert_color=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
Binary file added gui/translation/Images/flag_russia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions gui/translation/Images/flag_russia.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture2D"
path="res://.import/flag_russia.png-db862a3e8ae20d7b3763d8c62a913962.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Images/flag_russia.png"
dest_files=[ "res://.import/flag_russia.png-db862a3e8ae20d7b3763d8c62a913962.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/invert_color=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions gui/translation/Images/flag_spain.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture2D"
path="res://.import/flag_spain.png-3a4e246f2ff1e9ce06420c12869d3d76.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Images/flag_spain.png"
dest_files=[ "res://.import/flag_spain.png-3a4e246f2ff1e9ce06420c12869d3d76.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/invert_color=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions gui/translation/Images/flag_uk.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture2D"
path="res://.import/flag_uk.png-e848f7a2ca4ecb26caaf648f34528feb.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Images/flag_uk.png"
dest_files=[ "res://.import/flag_uk.png-e848f7a2ca4ecb26caaf648f34528feb.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/invert_color=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
Binary file added gui/translation/Images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions gui/translation/Images/icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture2D"
path="res://.import/icon.png-5c54608cdf98940b04ad240121483c81.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Images/icon.png"
dest_files=[ "res://.import/icon.png-5c54608cdf98940b04ad240121483c81.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/invert_color=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions gui/translation/Images/speaker.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture2D"
path="res://.import/speaker.png-93d8393c7bb602e281e4f3f01416d945.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Images/speaker.png"
dest_files=[ "res://.import/speaker.png-93d8393c7bb602e281e4f3f01416d945.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/invert_color=false
process/HDR_as_SRGB=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
4 changes: 2 additions & 2 deletions gui/translation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ the use of localized resources and texts.

Language: GDScript

Renderer: GLES 2
Renderer: Vulkan

## Screenshots

![Screenshot](screenshots/translation.png)
![Screenshot](translation.png)
43 changes: 43 additions & 0 deletions gui/translation/Scripts/translation_csv.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# For more information on localization,
# search Godot's online documentation "Internationalization", or visit
# https://docs.godotengine.org/en/latest/tutorials/i18n/index.html

extends Panel

func _ready():
_print_intro()

func _on_english_pressed():
TranslationServer.set_locale("en")
_print_intro()


func _on_spanish_pressed():
TranslationServer.set_locale("es")
_print_intro()


func _on_japanese_pressed():
TranslationServer.set_locale("ja")
_print_intro()


func _on_russian_pressed():
TranslationServer.set_locale("ru")
_print_intro()


func _on_play_pressed():
$Audio.play()


func _print_intro():
# In CSV translation, use the appropriate key in the Object.tr() function to fetch
# the corresponding translation.
# This is the same for scene nodes containing user-facing texts to be translated.
print(tr("KEY_INTRO"))

# CSV plural translation example.
var days_passed = randi() % 100
print(tr_n(days_passed, "KEY_DAYS") % days_passed)

Loading