[pmwiki-users] setXL to change language of the page?
Patrick R. Michaud
pmichaud at pobox.com
Thu Aug 3 10:14:45 CDT 2006
On Thu, Aug 03, 2006 at 04:48:44PM +0200, Thomas -Balu- Walter wrote:
> Hi all,
>
> not being able to find a directive that allows me to change the language
> of a page I thought I'd give it a trying with the following code:
>
> Markup('setXL', '>$[phrase]',
> '/\\(:setXL\\s+(\\S.*?):\\)/ei',
> "setXL('$1')"
> );
>
> function setXL($langs)
> {
> global $XLLangs;
> $args = ParseArgs($langs);
> $XLLangs = $args[""];
> }
>
> This adds a new directive (:setXL <languages>:). <languages> is a space
> separated list of the languages with the first one being preferred (e.g.
> "de en").
>
> Those languages have to be loaded first using XLPage();
>
> This is just a quick hack, so it might be the most evil piece of code in
> the world until Pm says something different ;).
It's not evil -- actually, it's completely within the design intent. :-)
> PS: I've noticed that my $XLLangs contains "de" two times - perhaps
> because I've loaded two pages - the default and my local one? Is this
> a feature or a minor bug that eats some ressources when searching for
> translations?
It's a minor bug affecting only performance, not functionality.
I think one can do
$XLLangs = array_unique($XLLangs);
to eliminate the duplication.
Pm
More information about the pmwiki-users
mailing list