Skip to content

Commit

Permalink
Update GUI Translation demo for 4.0
Browse files Browse the repository at this point in the history
- Add PO support in addition to CSV.

Co-authored-by: SkyJJ <[email protected]>
  • Loading branch information
Calinou and SkyLucilfer committed Jul 7, 2023
1 parent ea37c10 commit 0c48c79
Show file tree
Hide file tree
Showing 65 changed files with 991 additions and 507 deletions.
34 changes: 28 additions & 6 deletions gui/translation/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
# GUI Translation Demo

A demo showing how Godot seamlessly enables
the use of localized resources and texts.
This is a demo of how a project can be internationalized. Translations are
created in a CSV file and then imported into Godot.

Language: GDScript
For correct display, the font used must contain the glyphs required by the
target language. See the `fonts` folder for some fonts that you can use in your
project. Godot can load system fonts as a fallback, but this is not supported on
all platforms and the different visual design of system fonts can create
inconsistencies.

Godot allows internationalized text to change automatically when the locale is
modified. Resources can also be set to internationalized alternatives and replaced
automatically on locale change. This process is known as *remapping*.

Both CSV and gettext (PO/POT) approaches are showcased. Use the button in the
bottom-right corner to switch between the two approaches.

The resouce remapping process with PO is the same with CSV. The in-game text translation
process is also the same – use keys to fetch the appropriate translation.

Renderer: Vulkan Mobile
The main difference between PO files and CSV files is the way both of them store
the translated data in their files. Have a look at the `translations/po`
and `translations/csv` folders to see the files involved.

See [Internationalizing games](https://docs.godotengine.org/en/latest/tutorials/i18n/internationalizing_games.html)
and [Localization using gettext](https://docs.godotengine.org/en/latest/tutorials/i18n/localization_using_gettext.html)
for more information.

Language: GDScript

Check out this demo on the asset library: https://godotengine.org/asset-library/asset/134
Renderer: Compatibility

## Screenshots

![Screenshot](screenshots/translation.png)
![Screenshot](screenshots/translation.webp)
File renamed without changes.
24 changes: 24 additions & 0 deletions gui/translation/audio/hello_en.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://ciept8j0x21to"
path="res://.godot/imported/hello_en.wav-2eea592f221b07e3c37c5477c1da8173.sample"

[deps]

source_file="res://audio/hello_en.wav"
dest_files=["res://.godot/imported/hello_en.wav-2eea592f221b07e3c37c5477c1da8173.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_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
File renamed without changes.
24 changes: 24 additions & 0 deletions gui/translation/audio/hello_es.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://dd4xk00uh27hj"
path="res://.godot/imported/hello_es.wav-0b3ee7fc19ef7ac4822f3f3dc177c570.sample"

[deps]

source_file="res://audio/hello_es.wav"
dest_files=["res://.godot/imported/hello_es.wav-0b3ee7fc19ef7ac4822f3f3dc177c570.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_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
File renamed without changes.
24 changes: 24 additions & 0 deletions gui/translation/audio/hello_jp.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://3tnymbrsqo0w"
path="res://.godot/imported/hello_jp.wav-c7c916ef924fa85620d3858f227d094f.sample"

[deps]

source_file="res://audio/hello_jp.wav"
dest_files=["res://.godot/imported/hello_jp.wav-c7c916ef924fa85620d3858f227d094f.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_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file added gui/translation/audio/hello_ru.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions gui/translation/audio/hello_ru.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://dkuqg8u4fid5m"
path="res://.godot/imported/hello_ru.wav-490e2b267af12af16807f2bf3de6d995.sample"

[deps]

source_file="res://audio/hello_ru.wav"
dest_files=["res://.godot/imported/hello_ru.wav-490e2b267af12af16807f2bf3de6d995.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_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file removed gui/translation/flag_japan.png
Binary file not shown.
Binary file removed gui/translation/flag_spain.png
Binary file not shown.
Binary file removed gui/translation/flag_uk.png
Binary file not shown.
33 changes: 0 additions & 33 deletions gui/translation/font/DroidSans.ttf.import

This file was deleted.

33 changes: 0 additions & 33 deletions gui/translation/font/DroidSansArabic.ttf.import

This file was deleted.

33 changes: 0 additions & 33 deletions gui/translation/font/DroidSansFallback.ttf.import

This file was deleted.

33 changes: 0 additions & 33 deletions gui/translation/font/DroidSansHebrew.ttf.import

This file was deleted.

33 changes: 0 additions & 33 deletions gui/translation/font/DroidSansJapanese.ttf.import

This file was deleted.

33 changes: 0 additions & 33 deletions gui/translation/font/DroidSansThai.ttf.import

This file was deleted.

22 changes: 0 additions & 22 deletions gui/translation/font/droid_sans.tres

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 0c48c79

Please sign in to comment.