Textadventures > Localisation

Language Preprocessor

This is a cheap preprocessor for a one-level conditional compilation of Inform files. This could be used for a single source file containing the data for different languages.


perl inf-tags.pl [inf-compiler] {inf-options} -L[language-tag] [src] {game}

or possibly:

./inf-tags.pl [inf-compiler] {inf-options} -L[language-tag] [src] {game}

(Square brackets denote mandatory, curly braces optional items.)

[inf-compiler] is the Inform compiler to use, perhaps with a full path name prepended. [src] is the source file and {game} the game file to be written which defaults the the source's base name with a z-Code suffix.

{inf-options} are the usual options of the Inform compiler. The language tag must be specified. This can be any continous string of non-whitespace characters like EN, EN-UK or ENGLISH. The tag is case-sensitive. There is no default value.

Inside the source code, the text must be structured like this:

    :EN  "It is about two feet long.",
    :ES  "Mide aproximadamente sesenta centímetros.",
    :DE  "Es ist ungefähr einen halben Meter lang.",

That is, the text looks a bit like a switch statement. There is a line for every tag, the whole block is terminated with a single colon. With the -W option activated, a warning is issued when the block does not contain a definition for the requested language as for example would be the case if the above example hat be compiles with the tag IT. If the -W switch is set the compilation will not be started if there are empty blocks for that language tag.

It is important to close all tag blocks!

The tagging follows Inform Include statements, but it skips system files. This means that in any library file, the System_file; directive must be the first non-comment.

The script creates temporary source and output files. By default, these files are deleted after the script completes. With the -K option which must be on its own, the file is only converted and written to stdout so that it can be redirected with >.

The option -V (verbose) reports inclusion of files.

This is a Perl script and requires Perl 5. No special packages are required.

Known issues

The script assumes that the standard error style is -E0 (Acorn style messages). Since the script scans the output and replaces the temporary line numbers with line numbers in the tagged source, the correct error style must be known. You can wor around this by always specifying the error style with -E or by setting the defult error style in the script to something diffenent: just change the following line

    my $errorstyle = 0;


The method described here uses the "everything in one file" approach. This might be useful if one person writes all the text in several languages. The example below illustrates that it is easy to lose track of the game itself by adding too many languages. I would favour an approach that uses a game skeleton that can be filled with translations.

The method used in inf-tags.pl might be useful for small teams, though. (In fact, I am told it is currently being used for a bilingual project involving several authors.)

An example

Roberto Grassi from Italy, Urbatain from Spain and Eric Forgeot from France have reworked my original Jade example so that it includes an English, a German, an Italian, a Spanish and a French version in a single file:

Here it is, highlighted by language:

!    Multilingual Inform Game
!    Version  Nov. 2006

Constant Story


Constant Headline

 "^^Ein interaktives Beispiel^
    Viersprachige Version 2006 von
    Eric Forgeot, Roberto Grassi, Urbatain
    und Martin Oehm^^";
 "^^An interactive example^
    Multilingual version 2006 by Martin Oehm,
    Eric Forgeot, Roberto Grassi and
    El Clérigo Urbatain.^^";
 "^^Un esempio interattivo^
    Versione quattrilingue 2006 di Martin Oehm,
    El Clérigo Urbatain, Eric Forgeot
    e Roberto Grassi.^^";
 "^^Un ejemplo interactivo^
    Version cuatrilingue 2006 por Martin Oehm,
    Eric Forgeot, Roberto Grassi and
    El Clérigo Urbatain.^^";
 "^^Un exemple interactif^
    Version 2006 multilingue par Martin Oehm,
    Roberto Grassi, El Clérigo Urbatain
    et Eric Forgeot.^^";


Release 1;

Serial "030215"; !JJMMTT

Include "Parser";

Include "VerbLib";

[ Initialise;

    location = Lichtung;

    "Endlich! Nach tagelangem Suchen im Dschungel
        stößt du auf eine Lichtung. Und auf etwas mehr.
        Vielleicht ist dies der Ort, an dem sich die
        Jadestatue befindet?^^";
    "At last! After days of restless searching through
        the nearby jungle, you have come across a
        clearing. And something more. Maybe this is
        where you can find the fabled jade statuette?^^";
    "Finalmente! Dopo giorni di ricerca senza sosta
        nella vicina giungla sei giunto in una radura.
        E c'e' anche dell'altro. Forse sei vicino a
        trovare la famosa statuetta di giada?^^";
    "¡Al fin! Después de días de búsqueda sin descanso
        a través de la jungla cercana, has llegado a un
        claro. Y algo más. ¿Quizás es aqui donde podrás
        encontrar la legendaria estatuilla de jade?^^";
    "Enfin ! Après des jours d'exploration sans repos
        à travers la jungle, vous êtes arrivé à une
        clairière. Et bien plus. Peut-être est-ce ici
        que vous pourrez trouver la fabuleuse
        statuette de jade ?^^";


Object Lichtung

:DE    "Lichtung im Dschungel"
:EN    "Jungle Clearing"
:IT    "Radura nella giungla"
:SP    "Claro en la Jungla"
:FR    "Clairière dans la jungle"


    "Dort ist der Dschungel zu dicht, es gibt
        keinen Pfad in diese Richtung.",
    "In this direction, the jungle is too dense;
        There's no path in that direction.",
    "La giungla e' troppo densa in quella direzione;
        non ci sono sentieri percorribili.",
    "En esa dirección, la jungla es demasiado densa;
        No hay camino en esa dirección.",
    "Dans cette direction la jungle est trop fournie,
        il n'y a aucun chemin dans cette direction.",
 n_to Im_Schrein,
 in_to Lichtung,
 s_to [;

    if (Jadestatue notin player)

:DE "Nicht ohne die Statue!";
:EN "Not without the statuette!";
:IT "Non senza la statuetta!";
:SP "¡No sin la estátua!";
:FR "Pas sans la statuette !";
    deadflag = 2;

    "Du schaffst es, mit der Statue wieder zurück
    in die Zivilisation zu gelangen.";
    "You make it back to civilisation, and you got
    that statuette, too.";
    "Torni alla civilta'... con la statuetta.";
    "Vuelves a la civilización, y llevas la
    estatuilla además.";
    "Vous retournez à la civilisation, et vous
    avez avec vous la statuette.";

    "Du stehst auf einer Lichtung im
        dichten Dschungel. Im Norden steht ein alter,
        von Ranken überzogener Schrein. Im Süden führt
        ein schmaler Pfad zurück in die Zivilisation.",
    "You are standing on a clearing in a dense jungle.
        To the north there is an old shrine, overgrown
        with vines. A narrow track leads to the south
        and back to civilisation.",
    "Sei in una radura di una densa giungla. A nord vedi
        un vecchio tempio, coperto quasi interamente
        dalle radici. Un sentiero conduce a sud, verso
        la civilta'.",
    "Estás en un claro en la densa jungla.
        Al norte hay un santuario antiguo, envuelto
        en enredaderas. Un sendero estrecho conduce
        hacia el sur de vuelta a la civilización.",
    "Vous vous trouvez dans une clairière d'une jungle
        dense. Au nord se trouve un ancien tombeau,
        recouvert de lierre. Un petit sentier conduit
        au sud, vers la civilisation.",
has light;

Object -> Stein

:DE    "Stein"
:EN    "stone the size of your fist"
:IT    "una pietra grande quanto il tuo pugno"
:SP    "una piedra del tamaño de tu puño"
:FR    "une pierre grosse comme le poing"


    'faustgross' 'gross' 'rund' 'glatt' 'stein',
    dekl 3,
    adj "faustgroß",
    'stone' 'big' 'fist' 'size' 'sized' 'fist-sized',
    'pietra' 'grande' 'pugno',
    'piedra' 'grande' 'puño' 'tamaño',
    'pierre' 'grande' 'grosse' 'comme' 'taille' 'poing',


    "Der Stein ist so groß wie eine Faust
        und außergewöhnlich glatt und rund.",
    "The stone is about as big as your fist
        and it is incredibly smooth and perfectly
    "La pietra è grande quanto il tuo pugno. E'
        incredibilmente levigata e perfettamente
    "La piedra es tan grande como tu puño
        y es increiblemente suave y perfectamente
    "La pierre est environ grande comme votre poing,
        incroyablement lisse et parfaitement ronde.",


    "^In der Nähe des Schreins liegt ein
        glatter, runder Stein im Gras.",
    "^A smooth, round stone is lying in the grass
        by the shrine.",
    "^Una pietra levigata e circolare giace tra l'erba
        intorno al tempio.",
    "^Una piedra redonda y suave está tirada en la
        hierba al lado del santuario.",
    "^Une pierre ronde et lisse se trouve sur l'herbe
        dans les environs du tombeau.",
:DE male
:IT female
:SP female
:FR female

Object -> Schrein

:DE    "Schrein"
:EN    "shrine"
:IT    "tempio"
:SP    "santuario"
:FR    "tombeau"


:DE  'alt' 'toltekisch' 'schrein' 'efeu' 'ranken',
     dekl 1,
     adj "alt",
:EN  'old' 'toltec' 'shrine' 'temple' 'vines' 'weeds',
:IT  'vecchio' 'tolteco' 'tempio' 'costruzione'
:SP  'antiguo' 'toltec' 'santuario' 'templo'
:FR  'vieux' 'tolteque' 'tombeau' 'sanctuaire' 'lierre',


    "Der alte Toltekenschrein ist fast
        komplett mit Efeu überwuchert.",
    "The old Toltec shrine is completely
        overgrown with vines.",
    "Il vecchio tempio tolteco e' quasi completamente
        avvolto dalle radici.",
    "El antiguo santuario de Toltec está completamente
        lleno de enrredaderas.",
    "L'ancien tombeau toltèque est complètement
        recouvert de lierre.",

 before [;
            Enter: <>;
:DE male
:IT male
:SP male
:FR male

Object Im_Schrein

   "Im Schrein"
   "In the Shrine"
   "Nel tempio"
   "En el Santuario"
   "Dans le sanctuaire"

    "In dem kleinen Schrein ist es
        dunkel, nur wenig Licht fällt durch das halb
        verfallene Dach. Ein großer Lichtstrahl fällt
        auf eine Steinsäule in der Mitte des Schreins.
        ^^Die Lichtung liegt im Süden.",
    "It is dark inside the small shrine,
        only little light pours in through the broken
        roof. A wide beam of light illuminates a stone
        pedestal in the centre of the room, however.^^
        The clearing is to the south.",
    "Nel piccolo tempio regna l'oscurita', tuttavia
        una luce fioca filtra dal tetto danneggiato.
        Un raggio di luce illumina un piedistallo al
        centro della stanza.^^
        L'uscita e' a sud.",
    "Está oscuro dentro del pequeño santuario,
        sólo un poco de luz cae a través del tejado
        roto. Sin embargo, un ancho haz de luz
        ilumina un pedestal de piedra en el centro
        de la habitación.^^
        El claro está hacia el sur.",
    "Il fait sombre dans le petit tombeau, juste un peu
        de lumière passe à travers la toiture cassée.
        Un large rayon de lumière illumine un piédestal
        de pierre dans le centre de la pièce.^^
        La clairière est vers le sud.",
 s_to Lichtung,
 out_to Lichtung,
has light;

Object -> Saeule

:DE    "Steinsäule"
:EN    "stone pedestal"
:IT    "piedistallo di pietra"
:SP    "pedestal de piedra"
:FR    "piédestal en pierre"


 dekl 9,


:DE  'steinsaeule' 'saeule' 'steinpodest' 'podest',
:EN  'stone' 'pedestal' 'pillar',
:IT  'pietra' 'piedistallo',
:SP  'piedra' 'pedestal' 'pilar',
:FR  'pied' 'piedestal' 'pilier' 'roche',


    "Die Säule ist aus glattem Stein
        gehauen, etwas mehr als einen Meter hoch und
        oben flach, wie ein Podest.",
    "The pedestal is carved from smooth
        stone. It is about one metre high and has a
        flat top.",
    "Il piedistallo e' scolpito nella roccia.
        E' alto un metro ed ha una base piatta.",
    "El pedestal está formado por suaves labrados.
        Es como un metro de alto y la parte alta está
    "Le piédestal est taillé dans une roche lisse.
        Il fait environ un mètre de haut et a sa
        partie supérieure plane.",
:DE female
:IT male
:SP male
:FR male
supporter static concealed;

Object -> -> Jadestatue

:DE    "Jadestatue"
:EN    "jade statuette"
:IT    "statuetta di giada"
:SP    "estatuilla de jade"
:FR    "statuette de jade"



:DE 'gruen' 'klein' 'statue' 'figur' 'jadestatue'
     dekl 9,
:EN 'green' 'small' 'jade' 'figurine' 'statue'
    'statuette' 'idol',
:IT 'verde' 'piccola' 'giada' 'figurina' 'statua'
    'statuetta' 'idolo',
:SP 'verde' 'pequena' 'jade' 'figura' 'estatua'
    'estatuilla' 'idolo',
:FR 'verte' 'petite' 'jade' 'figurine' 'statue'
    'statuette' 'idole',


    "Es ist die Statue einer toltekischen
        Gottheit, komplett aus grüner Jade geschnitzt.
        Sie glänzt und sieht sehr wertvoll aus.",
    "It is the statue of a Toltec deity,
        crafted from green jade. It reflects the light
        beautifully and looks quite valuable.",
    "E' la statua di una divinita' tolteca, intagliata da
        una giada verde. Riflette la luce
        meravigiosamente e sembra di grande valore.",
    "Es una estatua de la deidad Toltec,
        tallada en jade verde. Refleja la luz
        de una manera hermosa y parece muy valiosa.",
    "C'est la statuette d'une divinité toltèque, taillée
        dans du jade vert. Elle reflète merveilleusement
        la lumière et semble avoir beaucoup de valeur.",
 before [;
    if (self in Saeule && ~~(Stein in Saeule))
        deadflag = true;

        "Als du das Gewicht der Statue von der
        Säule nimmst, hörst Du ein klickendes
        Geräusch. Kurz darauf wirst du von
        Giftpfeilen durchbohrt.";
        "As you lift the stauette's weight off
        the pedestal, you hear a klicking sound.
        A second later, you are pierced by poison
        "Appena sollevi la statuetta dal piedistallo,
        senti uno scatto. Un momento dopo, sei colpito
        da dardi avvelenati.";
        "En cuanto levantas la estatuilla del pedestal,
        escuchas un click. Un segundo después, tienes
        clavado un dardo envenenado.";
        "Tandis que vous soulevez le poids de la
        statuette hors du piédestal, vous entendez un
        cliquetis. Une seconde plus tard, vous êtes
        transpercé par une fléchette empoisonnée.";
has female;

:DE Include "GermanG";
:EN Include "Grammar";
:IT Include "ItalianG";
:SP Include "SpanishG";
:FR Include "FrenchG";


Startseite --> Textadventures --> Localisation --> lang.pl
Martin Oehm

URL dieser Seite: http://www.martin-oehm.de/adv/comp06.html

[ www.martin-oehm.de - Startseite ]
[ Textadventures ]
[ Localisation ]

Index [de]