Skip to content

Translation of level texts #670

Open
@Quintus

Description

@Quintus

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"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions