Hi,
I'm writing a site in PHP with mySQL. I've decided to have it in several
languages, but don't want to use XML just yet. So, I was wondering if
anyone has done it before and have some ideas. :)
Basically, I've come up with this: create include files with error
messages/page text/etc. and define 2-dimensional arrays, say:
global $errors;
$errors = array("id_error 1" => ("en" => "error in english",
"de" => "error in german",
"fr" => "error in french",
...
),
"id_error2" => ...
);
then define a function, say,
getLangText($ar ray,$id) {
global $$array;
global $lang;
$msg = $$array[$id];
return $msg[$lang];
}
where $lang is a global variable containing locality string. So, if we
need error1, we'd call:
echo getLangText("er rors","error1") ;
This would work, but I thought maybe someone has a more elegant solution :)
Thanks
I'm writing a site in PHP with mySQL. I've decided to have it in several
languages, but don't want to use XML just yet. So, I was wondering if
anyone has done it before and have some ideas. :)
Basically, I've come up with this: create include files with error
messages/page text/etc. and define 2-dimensional arrays, say:
global $errors;
$errors = array("id_error 1" => ("en" => "error in english",
"de" => "error in german",
"fr" => "error in french",
...
),
"id_error2" => ...
);
then define a function, say,
getLangText($ar ray,$id) {
global $$array;
global $lang;
$msg = $$array[$id];
return $msg[$lang];
}
where $lang is a global variable containing locality string. So, if we
need error1, we'd call:
echo getLangText("er rors","error1") ;
This would work, but I thought maybe someone has a more elegant solution :)
Thanks
Comment