[Chameleon-dev] [Bug 990] New: [Chameleon - Core] add capbaility to
load language resource files
bugzilla-daemon at maptools.org
bugzilla-daemon at maptools.org
Fri Mar 18 09:20:47 EST 2005
http://www.maptools.org/bugzilla/show_bug.cgi?id=990
Summary: [Chameleon - Core] add capbaility to load language
resource files
Product: Chameleon
Version: 2.2
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: Core
AssignedTo: chameleon-dev at lists.maptools.org
ReportedBy: pspencer at dmsolutions.ca
this is a small enhancement to provide a hook in the chameleon core to load
language-specific resource files. Resource files are php scripts that provide a
loadResources($oApp) function that does the actual loading.
Modifications are:
* add a new array maszResourceFiles to Chameleon to keep a single resource file
per language
* modify CWCAddRegionalTemplate to accept optional third parameter that
specifies the resource file
* modify CWCSetTemplate to include resource file and invoke loadResource
function if a resource file is set for the current template
Modifications will be done so that it everything will work exactly the same if
no resource file is provided. This provides the flexibility to use a single
template or multiple templates and manage translations either in the template or
in a separate file.
The initial intent is to have the loadResources() function insert
language-specific values using setVar so that template translation can be done
using [$str1|English$] type of syntax, removing the need for duplicated templates
In this model, the index.phtml file will contain:
$oApp->CWCAddRegionalTemplate( 'en-CA', 'sample_bilingual.html',
'resource_en.php' );
$oApp->CWCAddRegionalTemplate( 'en-CA', 'sample_bilingual.html',
'resource_fr.php' );
resource_en.php contains:
<?php
function loadResources( $oApp )
{
$aRes['str1'] = 'English';
$aRes['str2'] = 'fr-CA';
$aRes['str3'] = 'French';
foreach($aRes as $key=>$val)
{
$oApp->setVar($key, $val);
}
}
?>
resource_fr.php contains:
<?php
function loadResources($oApp)
{
$aRes['str1'] = 'French';
$aRes['str2'] = 'en-CA';
$aRes['str3'] = 'English';
foreach($aRes as $key=>$val)
{
$oApp->setVar($key, $val);
}
}
?>
and the template contains
current: [$str1|English$]
switch to: <a href="javascript:setLanguage('[$str2|fr-CA$]')">[$str3|French$]</a>
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
Please do NOT reply to this email, use the link above instead to
login to bugzilla and submit your comment. Any email reply to this
address will be lost.
More information about the Chameleon-dev
mailing list