Skip to content
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

Translation of level texts #670

Open
Quintus opened this issue Dec 2, 2019 · 1 comment
Open

Translation of level texts #670

Quintus opened this issue Dec 2, 2019 · 1 comment
Labels

Comments

@Quintus
Copy link
Member

Quintus commented Dec 2, 2019

Texts specific to a level are not currently translatable, but they should be. Since the translations for Gettext (which TSC's C++ code uses) have to be supplied at compile-time, it is not possible to do this with Gettext.

I propose an SSL extension that allows such translation. An SSL script would be used to implement the actual translation "engine" (something simplistic suffices for starting out), and the level scripts could then use that translation engine. The core C++ API would only need an extension in so far as that the detected user locale needs to be provided to the scripts (e.g. via addition of a method TSC::locale()).

For the level authors, it could then look like this in the level script:

require "ssl/i18n"

# Actual translation database
I18n.setup_translations do |t|
  t["en"].boxes.text.firstbox "This is the text for the first box"
  t["en"].boxes.text.secondbox "This is the text for the second box"

  t["de"].boxes.text.firstbox "Dies ist der Text für die erste Box"
  t["de"].boxes.text.secondbox "Dies ist der Text für die zweite Box"
end

# Find the objects to work with
box1 = UIDS[45]
box2 = UIDS[923]

# Attach the correct translation. The I18n::[] method calls TSC::locale() and
# takes care of selecting the correct translation string matching the found locale.
box1.text = I18n["boxes.text.firstbox"]
box2.text = I18n["boxes.text.secondbox"]
@Quintus Quintus added the Feature label Dec 2, 2019
@Quintus
Copy link
Member Author

Quintus commented Dec 2, 2019

Another approach (that also requires more work) is to extend the level editor's UI. The settings page could gain a new tab "text translations", where it picks up any in-game text (i.e. text boxes) and allows translation of that text. The translations are then saved into the level XML.

If this approach is chosen, it needs to be considered that level authors still need access to translations from a level's script, in order to show messages depending on conditions that can only be expressed with scripting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant