## ## wml::std::lang - Multi-Lingual Support ## Copyright (c) 1997-2001 Ralf S. Engelschall, All Rights Reserved. ## Copyright (c) 1999-2001 Denis Barbier ## # The / tags with multiple arguments require WML 2.0.3 #use wml::mod::version #use wml::std::tags # # The list of defined languages # # # The stack of language slices # # # Display current language and list of defined languages # # # The `lang:new xx' tag which adds another language to # the list of known ones and defines the `lang:xx' tag. # ] />> ] />" "" /> " 1 />> /> : attributes=verbatim>[:=LT=array-push __lang:stack />%%attributes=LT=set-var __dummy==LT=array-pop __lang:stack /> />:]=LT=/when>=LT=/define-tag> =LT=define-tag lang: endtag=required>[:=LT=array-push __lang:stack />%%body=LT=set-var __dummy==LT=array-pop __lang:stack /> />:]=LT=/when>=LT=/define-tag>" "=LT=" "<" /> />> : attributes=verbatim>[:=LT=array-push __lang:stack />%%attributes=LT=set-var __dummy==LT=array-pop __lang:stack /> />:]=LT=/when>=LT=/define-tag> =LT=define-tag endtag=required>[:=LT=array-push __lang:stack />%%body=LT=set-var __dummy==LT=array-pop __lang:stack /> />:]=LT=/when>=LT=/define-tag>" "=LT=" "<" /> # # The `lang:area' container tag # ] /> /> > \\)(.+?)(?=\\((?:[a-z]+|\\/)\\)|$)" ">\\1>" /> ] /> /> # # The ``lang:set-wildcard'' tag lets you define which wildcard to use # /> /> # # Sets the default wildcard # # # The ``lang:star:'' tag # The protection is for navbar # ] />> ] /> /> ] /> caseless=true />> ] /> />:%attributes:]" "" "] />" /> # # The specialized tag which # is a tag but enhanced for use # with URLs... # # Colons may confuse pass 3, e.g. in rollovers /> /> /> " action=delete /> /> />/> ] />> ] /> /> ] /> caseless=true />> " "" "] />" /> /> /> ] /> />::]" "" "] />" /> /> [LANG_] /> />::] />/> # # The ``lang:star:slice:'' tag # Another variant of to dynamically specify # the output filenames instead of using the wml shebang line # # This definition is really awful because it can deal with all # sort of situations # Former syntax: # * wml without command-line option (= wml -o %BASE.*.html) # * #!wml -o (ALL-LANG_*)+LANG_EN:foo.en.html # New syntax: # * #!wml -o (ALL-LANG_*)+LANG_**:foo.*.html # * #!wml -o (ALL-LANG_*)+LANG_**+FOO:foo.*.html \ # -o (ALL-LANG_*)+LANG_**+BAR:bar.*.html # " ".*.html" /> /> "<@[\*[^:]*$]@>" />> ":" /> ":.*$" action=delete /> /> " /> /> ".*:" action=delete /> /> /> /> /> /> /> /> /> " -o " ":" "<@[\*]@>" /> /> /> > "\n" /> /> /> /> ##EOF## __END__ =head1 NAME wml::std::lang - Multi-Lingual Support =head1 SYNOPSIS #use wml::std::lang (xx) ... (yy) ... ... ... =head1 DESCRIPTION This include file provides high-level multi-lingual support via Slices. Its purpose is to define the slices ``C'' according to the multi-lingual selection tags. The general intend of this slice-based approach is to use the defined slices in Pass 9 (Slice) via WMLs B<-o> option. A typical shebang-line example for the use with a webserver's content negotiation feature is: #!wml -o (ALL-LANG_*)+LANG_EN:index.html.en \ -o (ALL-LANG_*)+LANG_DE:index.html.de Since WML 1.7.0, the Clang:star:slice:E> tag is an alternative to this shebang-line. Before you can use a language, you have to define the corresponding tags via Clang:newE>. For instance when you want to use the languages english and german, use: Then the following tags are defined: ... ... i.e. for both languages a container tag and a simple tag is defined. The container tag is more readable while the simple tag is nicer for short variants. When the names C are still to large for you, you can use the C attribute to Clang:newE> when then leads to the defintion of the shortcut variants: ... ... Additionally you always have the Clang:areaE>...C/lang:areaE> container tag available which provides an alternative way of selecting the language in its body. It automatically surrounds the data between `C<(xx)>' start tags with the corresponding C slice. The following are equal: FooBar (xx)Foo(yy)Bar Because these three lines internally get expanded to [LANG_XX:Foo:][LANG_YY:Bar:] [LANG_XX:Foo:][LANG_YY:Bar:] [LANG_XX:Foo:][LANG_YY:Bar:] There is one additional special tag: Clang:star:E>. This tag expands its attribute line like the Clang:xx:E> tags but multiple times. Actually as much as defined languages exists (Clang:newE>!). And in each expansion the asterisks (=stars) in the data gets replaced by the language identifier. Is is sometimes convenient to use another wildcard, e.g. when defining navigation bars. The Clang:set-wildcardE> tag does the job. The attribute becomes the wildcard used in future substitutions. Without attribute, the default value is restored. You may specify any regular expression, and do not forget to escape special characters (the astersisk is in fact ``\\*''). There is a more specialized variant named Clang:star:href:E> which is similar to Clang:star:E> but treats its attribute value as a URL part and tries to check if it already exists. If it doesn't exist the tag expands the value without the star or an alternative value which can be appended with ``|alt-value''. The Clang:star:slice:E> is another variant to help writing multi-lingual files quickly. It must come after all occurences of Clang:newE> tags. The `C<%BASE>' form is recognized (see wml(1)) and an empty argument is equivalent to the string `C<%BASE.*.html>'. But note that the use of this tag instead of the WML shebang line prevents WMk from doing its job, because WMk can not guess output filenames in this case. For complex multi-lingual documents, you may want to know in which language text is currently processed. This is achieved with which always returns current language (as defined in Clang:newE> or an empty string when outside of any language portion. The macro prints the newline separated list of defined languages. =head1 EXAMPLE The following is an example of a webpage C with a multi-lingual header and hyperlink: #use wml::std::lang #use wml::std::href

When processed via $ wml index.wml The following two output files are generated (assuming that F and only F exists): index.html.en:

Welcome

The Hyperlink The Hyperlink index.html.de:

Willkommen

The Hyperlink The Hyperlink =head1 AUTHOR Ralf S. Engelschall rse@engelschall.com www.engelschall.com Denis Barbier barbier@engelschall.com =head1 REQUIRES Internal: P1, P2, P6, P9 External: -- =head1 SEEALSO wml_p9_slice(1) =cut