SammygoodTunes / Tile-Game

A tile-based multiplayer game with procedural terrain generation (using the Perlin Noise algorithm)
MIT License
1 stars 0 forks source link

Add translation #9

Open SammygoodTunes opened 1 month ago

SammygoodTunes commented 1 month ago

Implement text translation and a language menu.

onihilist commented 3 weeks ago

I can do that i guess if you want bro 🤠

SammygoodTunes commented 2 weeks ago

Sure.

Here's some info to get you started:

If you want to create a new language:

If you're adding a new translated text to one of the language files:

# en.yml
en:
  world:
    themes:
      default: Default
from game.utils.translator import translator as t  # Importing the translator module

t.t('path.to.translated.text')  # Getting the translated text using the translator

# The setter functions for changing the text varies from widget to widget: 
label.set_text(TEXT_HERE)  # For labels
button.label.set_text(TEXT_HERE)  # For buttons 
checkbox.title_label.set_text(TEXT_HERE)  # For checkboxes
selectbox.set_tooltip_text(TEXT_HERE)  # For selectboxes
# etc.

Feel free to look at the game/gui/screens/options_screen module if you need an example, the translation for that screen is done.

Si jamais tu vois des corrections à faire au niveau de ce qu'il y a déjà dans les fichiers yml (ou à l'avenir), n'hésites pas bien sûr.