stuartindigo

msg:4191872 | 10:22 am on Aug 25, 2010 (gmt 0) |
I wouldn't use a script based on initial domain called, but would suggest that based on the browser language preference is far better. The call would then be to PHP $_SERVER["HTTP_ACCEPT_LANGUAGE"] with redirects mirrored to the various language versions each in their own folder (eg to en/index.php, fr/index.php) There are plenty of scripts avilable in bath php and javascript for this purpose.
|
xnavigator

msg:4191874 | 10:43 am on Aug 25, 2010 (gmt 0) |
No i can't use this solution.. the web site on .de must be in Deutsch .fr in french etc
|
Sp4rkyM4rk

msg:4191932 | 12:55 pm on Aug 25, 2010 (gmt 0) |
This code will get the top level domain for you, so a domain name change shouldn't affect it too much, if at all. It doesn't give the full extension, but it's a start. So you'll find when echo'ing that you are not given 'co.uk' if you domain ends with that; you'll be given 'uk'. It essentially picks up the characters after the final dot in the domain name.
<?php
$activedomain = $_SERVER['HTTP_HOST'];
$tld = substr(strrchr($activedomain,'.'),1);
// Echo it to check
echo $tld;
// Statements to require the language files depending on the top level domain
switch ($tld) {
case 'uk': require ('en-uk.php'); break;
case 'de': require ('de.php'); break;
default: require ('en-us.php');
} ?>
|
xnavigator

msg:4191938 | 1:10 pm on Aug 25, 2010 (gmt 0) |
yea that is a solution
|
xnavigator

msg:4191945 | 1:28 pm on Aug 25, 2010 (gmt 0) |
problem is I use a template engine... so every phrase on the template must be wrote in the right language... i was thinking to do like CakePHP: every phrase is passed to a function like: func('Contact US'); the func checks the lanaguage and puts the right translation.. problem with is the dynamic contnent like a ttitle of a article: func('Read the $article_name'); $article_name would not be converted to the article title
|
xnavigator

msg:4191953 | 1:36 pm on Aug 25, 2010 (gmt 0) |
do u think using a func to auto-translate the phrase is a good solution? the func code would look like this:
function func($text) { $lang = get_language_from_domain(); if ($lang != default) { return $TableOfTranslation[$text]; } else return $text; }
looks ugly to me
|
superfast502

msg:4214613 | 4:24 am on Oct 10, 2010 (gmt 0) |
If I understand you correctly you are trying to use a single set of php files to deliver different content on different pages in different languages? How important are these sites to you? Why wouldn't you translate each of them and have them served separately where you could control the delivery? It would seem to me that the management of the php and code would far outweigh in difficulty and cost the trouble of setting up individual translated sites. Dunno, but that would be my guess. If using .php translate scripts, I have a great resource below. I hope that you can find some answers here or there [netbuilders.org...] Best of luck
|
paperso

msg:4214632 | 5:52 am on Oct 10, 2010 (gmt 0) |
Write a language files for each domains and set the appropriate language for each domains as default but let user change language if in case they prefer to use english. domain.fr the default language would be french and so on. If you use function to translate sometimes it's better to use define. func( LANG_CONTACT_US ); For dynamic contents, I guess google can do this or write a function to translate it.
|
paperso

msg:4214633 | 5:58 am on Oct 10, 2010 (gmt 0) |
My mistake, I included the define in a function. Use define() like this: English define('LANG_CONTACT_US', 'Contact Us'); French define('LANG_CONTACT_US', 'Contactez-nous'); Index.php <?PHP echo LANG_CONTACT_US; ?>
|
|