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

SteP step.list+pmwiki at gmail.com
Thu Jul 16 04:04:44 CDT 2009


I noticed that recipe Cookbook/MultiLanguage has never been updated to support the PTV markup 
{Group.Page$Title}. When the recipe is loaded and the markup is placed in page 
OtherGroup.OtherPage, the wiki outputs the title of OtherGroup.OtherPage (wrong), because the 
multilanguage recipe incorrectly resolves $Title (and $TitleSpaced). So here is a proposed fix for this 
issue. I really need some PmWiki experts to review it before I can update the online recipe.
I don't fully understand the implications of my proposed changes to other situations, like virtual pages, 
page name recipes, etc.

To test this fix, with PmWiki 2.2.2 only, I proceeded as follows.
Include local/multilanguage.php and set up at least three pages:
* Group1.Page1 with no (:title:) markup
* Group2.Page2 with (:title Title22:) markup
* Group3.Page3 with multilanguage title markup, i.e.,
  (:if userlang en:)(:title Title-en:)
  (:if userlang de:)(:title Title-de:)
  (:ifend:)
In page Main.WikiSandbox write markup:
  (:if userlang en:)(:title Sandbox-en:)
  (:if userlang de:)(:title Sandbox-de:)
  (:ifend:)
  t0 : {$Title}
  t1 : {Group1.Page1$Title}
  t2 : {Group2.Page2$Title}
  t3 : {Group3.Page3$Title}
Browse page Main.WikiSandbox?userlang=en and expect output:
  t0 Sandbox-en
  t1 Page1
  t2 Title22
  t3 Title-en  
Browse page Main.WikiSandbox?userlang=de and expect output:
  t0 Sandbox-de
  t1 Page1
  t2 Title22
  t3 Title-de

For review: diff of local/multilanguage.php
1c1
< 	function MultiLanguageTitle($pn,$name) {
---
> 	function MultiLanguageTitle($pn,$name,$group) { //SteP added $group
4a5,6
> 		if ( $pn != "$group.$name" ) //SteP added
> 			$pn = MakePageName("$group.$name","$group.$name"); //SteP added, would 
$pn = "$group.$name"; be better?

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?

Thanks,

--
  SteP




More information about the pmwiki-users mailing list