CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 changing path to html-files for multilang-support

Print topic Send  topic

Author Message
Tobias Weik
Posted: 09/05/2002, 11:33 AM

hi folks,

I´m using CCS 1.07 for PHP with Templates and was wondering if there is any way
to create some kind of multilang-support... basicly CCS is able to generate
differenty site-languages, but only one at the time :(

Since I´m using templates, I moved every database driven content to
multilang-support (by adding a row for langcode for each relevant table and
setting the primarykey on both, the id AND the langcode), so the only part that
contains some language relevant elements are the html-templates.

My idea was to create a subdirectory for each language ("/de", "/en" etc.) and
place the lang-edited html-templates there, keeping the PHP files in the parent
directory. Now I want to specify the needed html-template by setting the path
via selected language, but WHERE do I modify this path? If I place the
html-templates in a subdirectory and open the projectfile in CCS, it says that
the html-templates are missing and if I want to create new... HELP!

Thanx - Tobias
DonB
Posted: 09/05/2002, 5:19 PM

Try working with the OnInitializePageView event (this is a server-side,
page-level event). This fires before the template is loaded, so you ought
to be able to change the variable $TemplateFileName and select an
alternative template - for the language you want to appear.

Let us know how that works out.

thanks,


DonB


"Tobias Weik" <nospam@internet2go.de> wrote in message
news:3D77A381.8010407@internet2go.de...
> hi folks,
>
> I´m using CCS 1.07 for PHP with Templates and was wondering if there is
any way
> to create some kind of multilang-support... basicly CCS is able to
generate
> differenty site-languages, but only one at the time :(
>
> Since I´m using templates, I moved every database driven content to
> multilang-support (by adding a row for langcode for each relevant table
and
> setting the primarykey on both, the id AND the langcode), so the only part
that
> contains some language relevant elements are the html-templates.
>
> My idea was to create a subdirectory for each language ("/de", "/en" etc.)
and
> place the lang-edited html-templates there, keeping the PHP files in the
parent
> directory. Now I want to specify the needed html-template by setting the
path
> via selected language, but WHERE do I modify this path? If I place the
> html-templates in a subdirectory and open the projectfile in CCS, it says
that
> the html-templates are missing and if I want to create new... HELP!
>
> Thanx - Tobias
>

Tobias Weik
Posted: 09/05/2002, 6:59 PM

DonB wrote:
> Try working with the OnInitializePageView event (this is a server-side,
> page-level event). This fires before the template is loaded, so you ought
> to be able to change the variable $TemplateFileName and select an
> alternative template - for the language you want to appear.
>
> Let us know how that works out.

Hi Don,

thanx for your answer - I´ve been offline for the last hours, digging
into CCS and got it work, before I read your lines, so here is my result
how to do use CCS with more than one lang on site (using PHP4 with
templates!):

1) First of all, you got to get any piece of content that is filled up
by database (i.e. tables for listboxes!) to support multilang. I´ve done
this by adding a second row to each required table after the id called
"langcode", set this one and the id to be the primary key and filled it
with my entries for each lang ( so you get an "1, en, value01-english"
and an "1, de, value01-german" and so on). When you call a listbox, just
make to sure to have a parameter set for the lang (I use it the way:
"... AND langcode = "{UserLang}" -> see next step).

2) Next you need some kind of language identification - there are plenty
of ways to do this, I combined three(!) ways by adding a lang-selectbox
to my login (setting this value as session "UserLang"), defining a
user-lang at the user record and retrieving the HTTP_ACCEPT_LANGUAGE,
since I also want a lang-based loginscreen, if no user/session exists...

With step 1 and 2, you get the dynamic part supporting multilang, now we
need some solution for the "static" part, the html-templates. Since CCS
doesn´t support more than one language at the time on the site, you need
to use a little trick:

3) At designtime, CCS requires the html-template files to be placed to
the same folder like the *.php and *.ccp files (I didn´t get this
changed, mayby someone else does). The html-template files get published
with this structure, placed beside the *.php files, but you can edit the
"Templates.php" to look for them somewhere else at runtime! This is my
small hack on "Templates.html", beginning with "function clsTemplate()":
===

function clsTemplate()
{
$this->templates_path = "templates/de"; // defaultpath to
templates if no session is set and no lang identified!
$this->delimiter = chr(27);
$this->tag_sign = chr(15);
$this->begin_block = chr(16);
$this->end_block = chr(17);
}

function LoadTemplate($filename, $block_name)
{
if(!CCGetSession("UserLang"))
{
$acc_lang = getenv("HTTP_ACCEPT_LANGUAGE");
switch($acc_lang)
{
case "de":
$file_path = "templates/de/" . $filename;
break;
case "de_DE":
$file_path = "templates/de/" . $filename;
break;
case "de_AT":
$file_path = "templates/de/" . $filename;
break;
case "en":
$file_path = "templates/en/" . $filename;
break;
case "en_US":
$file_path = "templates/en/" . $filename;
break;
default:
$file_path = $this->templates_path . "/" . $filename;
}
}
else
{
$file_path = "templates/" . CCGetSession("UserLang") . "/" .
$filename;
}

if (file_exists($file_path))
{...dont edit from here on!...}

===
(I hope all linefeeds are shown correctly when sending this... sometime
Mozilla breaks my messages :))

Okay, we are almost done: Go to the folder where CCS publishes it files
to and create a subfolder called "templates" containing subfolders for
each lang (i.e. "/de", "/en"). Next and last step is to place the
published html-template files to the correct folder (depending on the
language you selected at your project-settings), copy them to the other
langfolders and translate them with some html-editor - thats it!
Remember to repeat the last steps anytime you edit and publish the
original files in your project, since the html-templates only get
published in one site-language and to the wrong place...

Just let me know if anyone finds this short tutorial usefull, I will
then add it to the "Tips and Articles" section at gotocode.com (I hope
my english isn´t too bad for this, I usually write german ones ;)
BTW: My next "hack" will be kind off multi-themes-support, adding
theme-selection to my users interface - let me know if this is
interessting two. Tobias

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.