InternationalPTVs
Description
Allow international characters in the names of PageTextVariables.
In the default installation, PageTextVariables can only have a name containing basic Latin/Roman (ASCII) letters, digits, dash and underscore. This is a limitation for international wikis. The recipe makes it possible to have variable names containing international characters in addition (or in place) of the basic Latin. With this recipe, PageTextVariables names can contain extended/accented Latin characters, Cyrillic alphabet, Greek alphabet, Chinese and other alphabets.
Installation
Add to a local config file these lines:
include_once('scripts/xlpage-utf-8.php'); $PageTextVarPatterns = array( 'var:' => '/^(:*[ \\t]*([\\w\\x80-\\xff][-\\w\\x80-\\xff]*)[ \\t]*:[ \\t]?)(.*)($)/m', '(:var:...:)' => '/(\\(: *([\\w\\x80-\\xff][-\\w\\x80-\\xff]*) *:(?!\\))\\s?)(.*?)(:\\))/s' ); Markup('textvar:', '<split', '/\\(: *[\\w\\x80-\\xff][-\\w\\x80-\\xff]* *:(?!\\)).*?:\\)/s', ''); Markup('{$var}', '>$[phrase]', '/\\{(\\*|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?[\\w\\x80-\\xff][-\\w\\x80-\\xff]*)\\}/', "i18n_ptv"); function i18n_ptv($m) { extract($GLOBALS['MarkupToHTML']); return PRR(PVSE(PageVar($pagename, $m[2], $m[1]))); } $PageListArgPattern = '((?:\\$:?)?[\\w\\x80-\\xff][-\\w\\x80-\\xff]*)[:=]';
Usage
You can use any international characters as variable names.
(:Adreça: Carrer Casa Blanca, Alcoi (PV):) (:Петко: "Petko" in Cyrillic alphabet:) (:檢視:Something in Chinese:) VoilàEnFrançais: Here you go in French * Петко : %navy%{$:Петко}%% * Adreça : %red%{$:Adreça}%% * VoilàEnFrançais : %blue%{$:VoilàEnFrançais}%% * 檢視 : %yellow%{$:檢視}%% From another page ([[PITS.01272]]): * Institució: %green%{PITS.01272$:Institució} %% * Telèfon: %red%{PITS.01272$:Telèfon} %% |
VoilàEnFrançais: Here you go in French
From another page (PITS.01272):
|
Notes
- Currently PageLists cannot work with international PageTextVariables,
- one could have
(:pagelist $:ïñţvàя=search:)
- but not
(:pagelist order=$:ïñţvàя:)
or use{=$:ïñţvàя}
in PageList templates.
- one could have
- PmSyntax doesn't correctly highlight international PageTextVariables.
Change log / Release notes
- 20121012 first release, ready to be tested.
See also
Contributors
Written by Petko.
Comments
See discussion at InternationalPTVs-Talk?
test
Here iPTVs like ={$Institució}
are not expected to work (yet):
name | Institució | Telèfon |
---|---|---|
01270 | {=$Institució} | {=$Telèfon} |
01271 | {=$Institució} | {=$Telèfon} |
01272 | {=$Institució} | {=$Telèfon} |
01273 | {=$Institució} | {=$Telèfon} |
01274 | {=$Institució} | {=$Telèfon} |
01275 | {=$Institució} | {=$Telèfon} |
01276 | {=$Institució} | {=$Telèfon} |
01277 | {=$Institució} | {=$Telèfon} |
01278 | {=$Institució} | {=$Telèfon} |
01279 | {=$Institució} | {=$Telèfon} |
[[#testfmt]] (:template first:) || border=1 ||! name ||! Institució ||! Telèfon || (:template each:) || [[{=$Group}/{=$Name}]] || {=$Institució} || {=$Telèfon} || [[#testfmtend]]
Here iPTVs like =$:Telèfon=*72*
should be expected to work but not order=$:Institució
(yet):
(:pagelist name=PITS.0127* $:Telèfon=*72* order=$:Institució:) |
(:pagelist name=PITS.0127* $:Telèfon=*72* order=-$:Institució:) |
User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.