Multilingual Navbars

Basic Usage

The basic usage is similar to wml::des::navbar. Most normal navbars should also work with navbar-FH.wml.

The preparation for splicing is mostly done by navbar:render (something may happen during the definition if a language is defined with the short attribute, but navbar-FH.wml should take care of this). navbar-FH.wml produces splices for all languages that are defined when navbar:render is called.

Specifying Language Versions

The txt, alt and hint attributes of navbar:button take a syntax that is similar to languages defined with the short attribute. In addition, a default value may be specified similar to the lang:star: syntax.

The attributes url and img of navbar:button now have a syntax similar to lang:star:href:, except that the character # is used for language substitution, since * is already used for the img attribute. If the url or img given is relative, the link will be set to the default page, unless the language specific page exists. As a result, you may have to run wmk -f twice if you add a version of a page in a new language. If you don't use the automatic button creation facility you better take care that at least the default images exist, if you use images at all.

A typical navbar:button definition might look like this:

   <navbar:button url=index.#.html|index.html
            img=ind.#.*.png|ind.*.png
            txt="<de: Leitseite><en: Homepage>|Leitseite">
If a default language is defined (see below), you may omit the specific definition for this language:
   <navbar:button url=index.#.html|index.html
            img=ind.#.*.png|ind.*.png
            txt="<en: Homepage>|Leitseite">
or you may omit the default and the specific definition for that language will be used as the default:
   <navbar:button url=index.#.html|index.html
            img=ind.#.*.png|ind.*.png
            txt="<de: Leitseite><en: Homepage>">
Otherwise, the first specified language will be used as the default, ore the whole string if navbar-FH.wml can't find anything it understands.

Note that all these attributes should only contain plain text and no other tags!

Default Languages

There is a new attribute defaultlanguage to navbar:define If set, the default values of all parameters are used for this language, instead of the properly substituted ones. Say, you have a button with img=ind.#.*.png|ind.*.png, and you generate slices for de, en and es. This will normally give you html-files with references to ind.de.n.png, ind.de.o.png, ind.en.n.png and so on, if these images exist or are created, and to ind.n.png etc. otherwise. If you set defaultlanguage=de, all occurences of ind.de.*.png etc. will also be replaced by ind.*.png. Similarily you can have <name>.html for the german pages and <name>.en.html for the english pages, and in case a page is not available in all languages, things should fall back to the default language fairly automagically.

This may or may not be a useful feature depending on your requirements. I implemented it because my site is mostly all german and I didn't want to change the existing urls of the type <name>.html to <name>.de.html when I translated some of my pages.

Strange Things

There is an attribute languages to navbar:render, which allows you to produces navbars for splices in languages that are not defined in your document. It's probably pretty useless, but it was easy to implement, and you never know.
Florian Hars <florian@hars.de>, 2007-10-15 (orig: 1999-03-14)