[pmwiki-users] a shortcut to switching languages in MultiLanguage

blues blues4u at supereva.it
Thu Sep 27 02:30:03 CDT 2007


On Thu, 27 Sep 2007 00:14:24 +0300, <alglt at yahoo.com> wrote:
> When using the MultiLanguage recipe, a page editor has to use the markup
> (:if userlang xx:)
> to switch to a different language. It is, I believe, quite tedious
> when translating a caption of an image to three languages, for example.
>
> Is there any sane reason why a line like this isn't used in
> multilanguage.php, to provide markup like (:en:) for language switching:
>
> foreach ($DefaultLanguages as $lang)
> {
>     Markup($lang, '<if',
>             "/\\(:$lang:\\)(.*)(?:\\(:(".implode('|',
>                             $DefaultLanguages)."|if):\\))?/Us",
>             "(:if userlang $lang:)$1");
> }
>
> or s/\$lang/l_$lang/ to avoid conflicts with other recipes?

yes, there is a reason. the reason is that when a page is saved the text
is parsed to find the defined languages and save the info as a page
attribute. this way the page get parsed only once (upon save) instead
than parse it each time it is referenced.
to do this the script searches for a (:if userlang xx:) inside the page
and just a (:en:) wouldn't be enough information for the script to know
that it is a language declaration.

i am thinking about a workaround, though, and this may change in the
future, i am already developing a new version.

blues




More information about the pmwiki-users mailing list