I would like to implement translation on a website and I'm trying out the method found at http://we-love-php.blogspot.com.ar/2012/07/how-to-implement-i18n-without.html
I can do it with ease when the page requested is a complete page but I don't know what to do when the requested page is composed of many included files.
Here what my index.php looks like:
<?php
include 'includes/header.php';
include 'includes/index.php';
include 'includes/footer.php';
?>
And what I've tried is to put the class inside each of the template files like this:
<?php
class example{
public function now() {
return <<<FOOBAR
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>MY SITE's TITLE</title>
<meta name="keywords" content="SOME KEYWORDS" />
<meta name="description" content="SOME DESCRIPTION">
<meta name="author" content="MY NAME">
...........
FOOBAR;
}
}
?>
That didn't work as it tries to create the class more than once. Then I've tried creating the class above header and then closing it after footer. It throw me an error as if PHP was trying to open footer first so then I rearranged the order of included files so it includes footer.php first and header.php last. Not only it came out as a mess but also with a warning message at the bottom saying:
Parse error: syntax error, unexpected end of file, expecting variable
How can I solve this? I liked this method of translating my site but need it to work while including templates. Is it possible?
Thanks in advance!