TranslatorScript

Willkommen in der Transport Fever Community

Wir begrüßen euch in der Fan-Community zu den Spielen Transport Fever und Train Fever, den Wirtschaftssimulatoren von Urban Games. Die Community steht euch kostenlos zur Verfügung damit ihr euch über das Spiel austauschen und informieren könnt. Wir pflegen hier einen freundlichen und sachlichen Umgang untereinander und unser Team steht euch in allen Fragen gerne beiseite.

 

Die Registrierung und Nutzung ist selbstverständlich kostenlos.

 

Wir wünschen euch viel Spaß und hoffen auf rege Beteiligung.

Das Team der Transport-Fever Community


Sie betrachten gerade eine ältere Version des Eintrags. Klicken Sie hier, um zur aktuellen Version zu gelangen.

  • Manual for TranslatorScript (for modding purpose).
    [img]http://ftp.train-fever.net/flaggen/de.png[/img] [url='http://www.train-fever.net/lexikon/index.php/Entry/85']Die deutsche Version gibt es hier[/url] [img]http://ftp.train-fever.net/flaggen/gb.png[/img] This litte script mod adds the possibility to translate (prepared) mods by just adding a language file. [h1]Benefits & Compatibility[/h1] To translate the text of a model you normally have to provide a unique *.mdl-file for each language. Well, you think this is not a problem? Imagine you have to change a few numbers in your model. You have to do the changed in every file! Support is complex and time intensive. With TranslatorScript you just have to provide one single *mdl-file for each model. The language data is outsourced to a language file. The user installs the language he wants beside your mod. TranslatorScript will do all the language integration into the mod. Only the language files themself must be made by hand. Do you worry, that if TranslatorScript is not installed on your users installation, he can't use your mod? You don't need to. The include will just be skipped by Train Fever if TranslatorScript is not installed. Your mod will not be broken. [box][color=#831555]If someone has not installed TranslatorScript this will [u][b]NOT[/b][/u] break your file![/color][/box] [h1]Preparations[/h1] [h2]1) Include TranslatorScript[/h2] Add the following code at the first line of your *.mdl-file: [code]pcall(require, 'BR146_translate_script')[/code]This line will be skipped if TranslatorScript is not installed. [h2]2) Setting Up Your Text[/h2] Each text has to be surrounded with [tt]_("YOUR TEXT")[/tt]. The important characters are the underscore and the brackets. "YOUR TEXT" will be shown if[list][*]no translation is installed [*]the translation for this text is missing [*]TranslatorScript is not installed [/list] [h1]Language File Configuration[/h1] The language file is located at the same place as your *.mdl-file. The name is the same one as your *.mdl-file, but with one difference: instead of ".mdl" it's [b]file extention[/b] is [b]".lang"[/b]. The file has to be encoded as [b]UTF-8[/b]. For example, your model file is located at [tt]res\models\model\yourModel.mdl[/tt], the location of the language file has to be [tt]res\models\model\yourModel.lang[/tt] The language file has the following syntax: [code]return { ["Orignaltext mit Leerzeichen"] = "the translation is in here", ["zweitens"] = "second line", ... }[/code] [box][b][color=#831555]A user only can have installed ONE language file at once! Or no language file, so your original text is used.[/color][/b][/box] [h1]Example[/h1] This example shows the skeleton of a *.mdl-file. The text to translate is "Signal" and "Signal von BR146". If only the mod is installed, Train Fever will show those two. If the language file (and TranslatorScript of course) is installed, "Segnale" will be shown instead of "Signal" (the same with the other text). If a text is missing, the original text from the mod is shown. [h2]Model File[/h2] [code]pcall(require, 'BR146_translate_script') function data() return { [...] metadata = { description = { name = _("Signal"), description = _("Signal von BR146") }, [...] } end[/code] [h2]Language File[/h2] [code]return { ["Signal"] = "Segnale", ["Signal von BR146"] = "Segnale (BR146)", }[/code]

    1 Links

    [url='http://www.train-fever.net/index.php/Thread/2351']discussion thread[/url] [url='http://www.train-fever.net/filebase/index.php/Entry/727']download[/url]

Teilen