Author Topic: Language select by URL  (Read 5570 times)

0 Members and 1 Guest are viewing this topic.

Offline Grutho

  • Newbie
  • *
  • Posts: 14
    • View Profile
Language select by URL
« on: May 07, 2006, 11:44:27 AM »
Hi everybody,

I am looking for a solution to change the language by the domain-adress.

For example: if I use bei .de domain, the language german will be used. If I use the .com domain adress, the englisch language pack will used.

Have enyvone an idea, i'am think, there must be an easy an stabil soltion for an language switsch.

Thanks for your Help,
Tom
« Last Edit: May 07, 2006, 12:30:07 PM by Grutho »

Offline bibabobu

  • Sr. Member
  • ****
  • Posts: 311
  • Technische und künstlerische Gravuren
    • View Profile
    • Technische und künstlerische Gravuren für die gesamte Metall-, Kunststoff- und Papierindustrie
Re: Language select by URL
« Reply #1 on: May 07, 2006, 01:07:46 PM »
Good idea.
I am also searching for a solution.
My site is running under a lot of different domains.
So I also would like to have with the .de domain german language
and for my .eu domains the english language.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Language select by URL
« Reply #2 on: May 07, 2006, 01:21:19 PM »
In global.php find:
Code: [Select]
$config['language_dir_default'] = $config['language_dir'];
Insert below:
Code: [Select]
$array = array(
  "de" => "deutsch",
  "com" => "english",
);
$ext = substr(strrchr($_SERVER["SERVER_NAME"],"."), 1);
if (isset($array[$ext]))
{
  $config['language_dir'] = $array[$ext];
}

you can add as many domain sufixes as you wish. Also it will not affect normal language switching feature in 4images.
« Last Edit: May 07, 2006, 01:45:59 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Grutho

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Language select by URL
« Reply #3 on: May 07, 2006, 01:34:06 PM »
Thanks V@no,

that was a fast and perfect help... as i accustomed from you... best wishes and a nice weekend.
Tom

Offline bibabobu

  • Sr. Member
  • ****
  • Posts: 311
  • Technische und künstlerische Gravuren
    • View Profile
    • Technische und künstlerische Gravuren für die gesamte Metall-, Kunststoff- und Papierindustrie
Re: Language select by URL
« Reply #4 on: May 07, 2006, 01:39:45 PM »
Sorry,
I receive this error message
Quote
Fatal error: Call to undefined function: get_file_extension() in /is/htdocs/wp1015398_0TDZ7CIHLH/www/galerie/global.php on line 280

my code part  in global.php
Quote
$config['language_dir_default'] = $config['language_dir'];

//Lang Select for different Domain extensions START
$array = array(
 "de" => "deutsch",
 "com" => "english",
 "org" => "english",
 "net" => "english",
);
$ext = get_file_extension($_SERVER["SERVER_NAME"]);
if (isset($array[$ext]))
{
 $config['language_dir'] = $array[$ext];
}
//Lang Select for different Domain extensions END
$l = null;
if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
  $l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
  if (file_exists(ROOT_PATH.'lang/'.$l.'/main.php')) {
    $config['language_dir'] = $l;
    setcookie('4images_lang', $l, (time()+ 60 * 60 * 24 * 365), "/", "", 0);
  }
}
else
{
  if (isset($HTTP_COOKIE_VARS['4images_lang']) && file_exists(ROOT_PATH.'lang/'.$HTTP_COOKIE_VARS['4images_lang'].'/main.php'))
  {
    $l = $config['language_dir'] = $HTTP_COOKIE_VARS['4images_lang'];
  }
}
if ($config['language_dir'] == $l) $config['template_dir'] .= "_".$l;
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']);
define('ICON_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']."/icons");

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Language select by URL
« Reply #5 on: May 07, 2006, 01:46:42 PM »
This was ment for v1.7.2

I've change one line, try now.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline bibabobu

  • Sr. Member
  • ****
  • Posts: 311
  • Technische und künstlerische Gravuren
    • View Profile
    • Technische und künstlerische Gravuren für die gesamte Metall-, Kunststoff- und Papierindustrie
Re: Language select by URL
« Reply #6 on: May 07, 2006, 02:12:29 PM »
Ok. Thank you. No more error message!  :wink:
But my hoster links me with every of my domains to my default domain content.
So i think i'll have to change the link to the right content site at the hoster configuration too.