SuperTux Bug Tracker
SuperTux logo


View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000842supertuxTranslationspublic2011-08-27 07:372015-11-29 10:01
Reportergrumbel 
Assigned ToTobbi 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version0.3.3-SVN 
Target VersionMilestone 2Fixed in VersionMilestone 2 
Summary0000842: SuperTux can't translate strings in user script files
DescriptionSuperTux can translate strings in a .stl file when the user provides a proper .po file for it in the same directory. SuperTux however can't translate strings inside scripts inside that .stl file.

So something like:

(supertux-level
  (name (_ "A Loud Night"))
  ...

will translate fine. While something like:

    (scripttrigger
      (script "Text.set_text(translate(\"text to be translated\"));")

will not.

The reason for this is that SuperTux uses multiple dictionaries, a global one for all the SuperTux core functionality that reads from "data/locale/" and a local one that is created on each lisp::Parse(). The later one is however only used to translate (_ ...) constructs inside the lisp files, it does not handle anything else and is discarded afterwards.

A proper fix for this would be to get rid of the whole (_ ...) handling inside the lisp parser and move it out into user code where it belongs. The user code could then share a single dictionary manager with the rest of the game.

If conflicts in the strings are an issue, it might also be possible, but more complicated, to create a separate dictionary manager for each user add-on.

A further complication is that lisp::Parser() currently uses the native filesystem for it's DictionaryManager, while the global DictionaryManager one uses Physfs. So just ripping the local DictionaryManager out and replacing it with a global one doesn't work, it needs further hacking.
TagsAttachedFiles
Fixed in GIT revision
Fixed in subversion revision
Attached Filesdiff file icon stpatch-dictionary-in-world.diff [^] (13,474 bytes) 2011-08-31 02:34 [Show Content]

- Relationships
related to 0000106closed (Scripting) extract translatable strings from the scripts 

-  Notes
(0002549)
user767
2011-08-27 10:28

Combining the Lisp and the global Dictionary would need patching tinygettext because we only have DictionaryManager::add_directory but not remove_directory which would be needed to keep the directory stack clean.
I propose keeping a second dictionary but moving it from lisp::Parser to World. Maybe I'll write a patch if i have time tonight.
(0002573)
rgcjonas (reporter)
2011-08-31 02:33

I wrote a patch moving the dictionary manager to World. I had to reorganize some things in the code. The patch solves the problem of translate() but Lisp::Parser is still involved in translating. Maybe the approach to use World as location for the DictionaryManager is just wrong.
(0002700)
mol1 (reporter)
2011-09-14 04:47

So, can I translate the text if I apply the patch ???
(0002701)
rgcjonas (reporter)
2011-09-14 06:30

Yes. But I'm pretty sure the patch isn't good. It just moves some things around and while i generally like the approach i'm not happy with the implementation in this patch. Like grumbel said, translation handling should be completely moved out of the Lisp* classes. And we could simplify it a lot by using just one dictionary, but that could lead to conflicts if levels use the same strings like the core (I don't think it would happen that much but I'm not a level designer. It's worth a discussion).
(0003803)
Tobbi (administrator)
2015-11-29 10:01

I added some python scripts to extract translatable strings from scripts and create a temporary file which xgettext can parse, for add-ons as well as main scripts.

- Issue History
Date Modified Username Field Change
2011-08-27 07:37 grumbel New Issue
2011-08-27 10:28 user767 Note Added: 0002549
2011-08-31 02:33 rgcjonas Note Added: 0002573
2011-08-31 02:34 rgcjonas File Added: stpatch-dictionary-in-world.diff
2011-09-14 04:47 mol1 Note Added: 0002700
2011-09-14 06:30 rgcjonas Note Added: 0002701
2012-09-08 06:22 superdev Tag Attached: AttachedFiles
2014-08-18 00:59 grumbel Relationship added related to 0000106
2015-11-29 10:01 Tobbi Status new => resolved
2015-11-29 10:01 Tobbi Resolution open => fixed
2015-11-29 10:01 Tobbi Fixed in Version => Milestone 2
2015-11-29 10:01 Tobbi Target Version => Milestone 2
2015-11-29 10:01 Tobbi Note Added: 0003803
2015-11-29 10:01 Tobbi Assigned To => Tobbi


Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker