Hi,
I'm working on a way to parse a html template using perl.
Why :
- I'm designing a multilangional site (Dutch/Frech/English/German)
- Site maintainer should be able to edit all statical text that's displayed
on each page
- I only want to make one template for each page it should display (so no
matter what language would be called)
How i think of doing this :
1. Create a csv-file which holds the text of all pages in a format like :
Page|Variable|Lang|TEXT
e.g : home|varTxtWelcome|e|Welcome to our website\nWe hope you enjoy
our now layout!
home|varTxtWelcome|n|Welkom op onze nieuwe website\nHopelijk
bevalt onze nieuwe layout je!
home|varTxtWelcome|f|Bienvenue sur notre nouveau site\n
....................... etc....etc...
Before someone asks : i want the data for each language/variable to be
on a seperate line in the csv, so i can use the same script over and over
again, no matter how many languages i would like to support :-)
2. Create a html file which holds home-made tags which should be replaced
with the correct csv-file variables
e.g. : <P>%varTxtWelcome%</P><P
align=center>%varTxtSiteIntroduction%</P>
note: multiple home-made tags should be allowed on each line in the
template file!
note: right now i'm using the next tag format : !!varTxtWelcome!! in
stead of %varTxtWelcom%
Thus, when calling for example http://127.0.0.1/view?language=e&page=home,
this should result in the template file called home to be parsed and dumped
with the right language bits from the csv-file.
My knowledge : hmmm... i've already written lots of basic perl scripts but
i'm not really into regex and stuff, so i'm asking some help from you guys
:-) I know how to do the lookups in the csv and how to read in the template,
so it's the parsing stuff that got me at the moment..
My question : Does anybody know how to handle the parsing bit which i should
use? Any regex examples? What would be nice is that the script would be
'variable-independent' > with this i mean that i do not have to alter the
script each time i wish to add a new variable in the csv-file > which is by
the way i'm doing things right now and i'm convinced a lot of you guys will
reply that i'm stupid. As an example of how stupid : $line =~
s/!!activities!!/$activities{$lang}/eg; What is would like to accomplish is
that the parsing bit searches for anything between !!-!!'s (or %-%'s) and
looks up that var in the csv file (so no var hardcoding in the script)...
In hope someone understands what i'm trying to achieve...
Thanks for any replies, examples, modules who could be useful, etc!
$ThierryBotten = $SimplePerlGuy;-)
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web