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.

    1 Benefits & Compatibility

    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]

    2 Preparations

    2.1 Include TranslatorScript

    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.

    2.2 Setting Up Your Text

    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]

    2.3 File Encoding

    The *.mdl-file must be encoded as [color=#831555][b]UTF-8[/b][/color].

    3 Language File Configuration

    3.1 File Location

    [box][b][color=#831555]A user only can have installed ONE language file at once! If no language file is installed, your original text is used.[/color][/b][/box] The path to the language file is generated as followed: For a model in [tt]res\models\model\[/tt] the location of the language file will be [tt]res\strings\models\[/tt]

    3.1.1 Language File For Entire Folder

    For all * .mdl files in a shared folder, a single language file can be used. The name of the language file is then [tt]_TRANSLATION.lang[/tt]. [b]Example:[/b] If the files are located in the path [tt]res\models\model\railroad\BR146[/tt], then he location of the language file is [tt]res\strings\models\railroad\BR146\_TRANSLATION.lang[/tt].

    3.1.2 Language File For Single *.mdl-File

    For singe *.mdl-files - even in the same folder - can individual language files be used. The name is then formed from the file name of the *.mdl-file without the file extension (.mdl) and the suffix [tt].lang[/tt]. [b]Example:[/b] If your model file is located at [tt]res\models\model\railroad\yourModel.mdl[/tt], the location of the language file is [tt]res\strings\models\railroad\yourModel.lang[/tt].

    3.2 Syntax

    The language file consists of as many lines as in this example: [code]return { ["Orignaltext mit Leerzeichen"] = "the translation is in here", ["zweitens"] = "second line", ... }[/code]

    3.3 File Encoding

    The language file must be encoded as [color=#831555][b]UTF-8[/b][/color].

    4 Example

    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. [size=12]model file[/size] [code]pcall(require, 'BR146_translate_script') function data() return { [...] metadata = { description = { name = _("Signal"), description = _("Signal von BR146") }, [...] } end[/code] [size=12]language file[/size] [code]return { ["Signal"] = "Segnale", ["Signal von BR146"] = "Segnale (BR146)", }[/code]

    5 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