12-17-2008, 05:16 AM
I did the translation system with the replacements in the output.
I used str_replace() and not ereg_replace() because ereg_replace can't handle HTML and this has to be because otherwise the error like I said in post 5 happens. I have not coded a system to choose language in THT, that still has to happen.
This is what I already have:
includes/output.php
includes/language.php
It's quite simple, but the translation is the most work! (I'll translate it into Dutch)
I used str_replace() and not ereg_replace() because ereg_replace can't handle HTML and this has to be because otherwise the error like I said in post 5 happens. I have not coded a system to choose language in THT, that still has to happen.
This is what I already have:
includes/output.php
PHP Code:
<?
//include the language files
include ('language.php');
$language = new lang();
#Sort the errors
if($_SESSION['ecount'] == 1) {
$_SESSION['ecount'] = 0;
$_SESSION['errors'] = 0;
}
else {
$_SESSION['ecount'] = 1;
}
$data = ob_get_contents(); # Get all the HTML created by the script
ob_end_clean(); # Erase that data
echo $language->translate($style->prepare($data)); # Prepare, translate and output it
?>
includes/language.php
PHP Code:
<?
class lang {
public function translate($output) {
$original = array();
$replacement = array();
//language files start
$original[0] = 'English text';
$original[1] = '<td>Client Area</td>';
$replacement[0] = 'translated test';
$replacement[1] = '<td>Client Area translated</td>';
//replaces the english output by the foreign language
return str_replace($original, $replacement, $output);
?>
It's quite simple, but the translation is the most work! (I'll translate it into Dutch)