[pmwiki-users] need expert review - multilanguage recipe change

Hans design5 at softflow.co.uk
Sat Jul 18 02:04:19 CDT 2009


Thursday, July 16, 2009, 10:04:44 AM, SteP wrote:

> BONUS QUESTION
> If you have time, I'd appreciate suggestions on how to evolve the
> multilanguage recipe with respect to  title caching.
> Currently this recipe can only cache multilanguage titles if they appear in markup like
> (:if userlang xy:)(:title The xy title:)...
> (Search multilanguage.php for the last occurrence of string "mltitle" to see how it does it)
> I would like to add a more flexible approach, but I'm not sure
> which one, so I'm open to suggestions. 
> One idea could be to match a set-PTV pattern, such as (:xyTitle:The
> xy title:). One advantage of PTV vs. 
> (:if:) is that it's easier to mix with other conditional markup. Thoughts / ideas?

I suggest to use a multi-language title markup:
(:title-en An English Title:)
(:title-de Ein deutscher Titel:)

This can be done with code like

## (:title-lang :)
foreach($DefaultLanguages as $lang) {
  $title = 'title-'.$lang;
  Markup($title,'directives',
    '/\\(:(title-'.$lang.')\\s(.*?):\\)/ei',
    "PZZ(PCache(\$pagename,
     \$zz=array(PSS('$1') => SetProperty(\$pagename, PSS('$1'), PSS('$2')))))");
  $SaveProperties[] = $title;
}

The whole last part of multilanguage.php will not be needed then:

        array_unshift($EditFunctions,'SaveLanguages');

        function SaveLanguages($pagename, &$page, &$new) {
        ......
        ......

But we need to declare all the language strings we want to use
in array $DefaultLanguages. This array may need to be renamed
to reflect this change of use of it.

Also in function MultiLanguageTitle any occurence of
'mltitle-' should be written as 'title-'.

One other problem:
By not using function SaveLanguages we loose the automatic page
attribute creation of languages= (and languages in page, and select
language markup).
We could declare languages in a page with a new (:languages ...:)
markup, but maybe that is too clumsy.
Or we use function SaveLanguages, but without the last part for
picking out strings (:if userlang XX:)(:title yyyyy:)


  ~Hans




More information about the pmwiki-users mailing list