A little Perl script to manage multi-languages webpages

Version francaise / Deutsche Übersetzung


A website using mlhtml: ATALA (see also this page)


Why such a script ?

Aim : To be able to generate a webpage per language from a unique file, with the minimum amount of typing.

   I tried to write the entire content of this site in the three languages french, german and english, so that they have an equal status. It is rather tiresome, but I use, in order to avoid typing the whole pages three times, a Perl script, mlhtml2html, that translates what I call MLHTML (multi-language HTML) into HTML, so that I need to type in three times only the words .

   There are some HTML preprocessors (for example htmlpp by Isil, or this other htmlpp). But I wished tags as short as possible, whereas, in those preprocessors, they are longer. Sample:

In MLHTML <h1>%frBonjour%enHello%deHallo%^ !</h1> %!frVersion française ici%frCette page est en français.%^
With Isil's htmlpp <h1><#fr>Bonjour</#fr> <#en>Hello</#en> <#de>Hallo</#de> !</h1> <//#fr>Version française ici <#fr>Cette page est en français.</#fr>
With the other htmlpp <h1>.if ("$(LANG)" eq "fr")
Bonjour !
.elsif ("$(LANG)" eq "en")
Hello !
.elsif ("$(LANG)" eq "de")
Hallo !
.endif </h1>
.if ("$(LANG)" ne "fr")
Version française ici
.else
Cette page est en français.
.endif

   Anyway, mlhtml2html was designed to be able to be used simultaneously with a preprocessor : you simply can execute it first, and then execute the preprocessor on the result.


Download the script

  N.B. This software is distributed in the hope that it will be useful, but without any warranty .


Documentation of mlhtml2html

With the aid of samples Rational presentation
Let's make a page with name "index.html", that displays "hello" in the different languages. There will be at the end "index.html.fr", "index.html.de", "index.html.en", which will be automatically selected by the web server, according to the language of the reader.

  1. We create the file "index.html.mlhtml", with :

    <html lang="%frfr%enen%dede">
    <head>
    </head>
    <body>
    <h1> %fr Bonjour %en Hello %de Hallo %^ ! <h1>
    (The blanks between tags and words are superflous)
    </body>

  2. We execute the command :
    mlhtml2html index.html.mlhtml -fr -de -en
    where the different languages are given with -xy .
  3. That's all ! The three files were generated.
  1. The language :

    Samples :
    <h1>%frBonjour%enHello%^ !</h1>
    %!frVersion française%frAutres langues%^
    %enThis text is not 100%% mistake-free...%^

  2. Syntax of the launching command :
    mlhtml2html -lang1 -lang2... [files] [--] [files]
    One file per language is generated.
    The -- parameter is optional. It is used to indicate that the next arguments aren't any more languages indications, but files. Its use is necessary if one of the files to process has a name with an initial -.

    N.B. If no file to process is given, data will be read from STDIN. Then only the first language will be processed.


  You can write to me by e-mail at following address: Christophe.Deroulers @ ens.fr (Especially if you find some english mistakes in this page... It will be a pleasure for me to correct them.)

Back to the index - Back to the list of the homepages of the ENS