• [MOD] Language select 4 0 5 1
Currently:  

Author Topic: [MOD] Language select  (Read 296585 times)

0 Members and 2 Guests are viewing this topic.

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
[MOD] Language select
« Reply #15 on: May 17, 2003, 06:57:42 AM »
Quote from: noyou
can you tell me the size for the gif file, 80*60 is good? :)
:lol: hehe whatever your eyes would enjoy :wink:
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 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
[MOD] Language select
« Reply #16 on: May 24, 2003, 02:01:02 AM »
This little addon could help to someone who likes to add lots of new stuff into 4images (like myself :D).
Sometimes I work with /english/main.php, add some new lang text, but dont have time or wish, at the moment, add/translate that text for the rest of languages I use on my site. So, this addon will use "default" language text to replace missing translation for other languages. Otherwise if there is missing some translation text, it will display just empty blank spaces.

Open /global.php
Find:
Code: [Select]
include(ROOT_PATH.'lang/'.$config['language_dir'].'/main.php');
Replace with:
Code: [Select]
$lang_eng = "";
if ($config['language_dir'] != $config['language_dir_default']) {
include(ROOT_PATH.'lang/'.$config['language_dir_default'].'/main.php');
$lang_eng = $lang;
}
include(ROOT_PATH.'lang/'.$config['language_dir'].'/main.php');
if ($lang_eng) {
foreach ($lang_eng as $key => $val) {
$lang[$key] = ($lang[$key]) ? $lang[$key] : $lang_eng[$key];
}
}
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 mantra

  • Sr. Member
  • ****
  • Posts: 358
    • View Profile
    • DREAM WITH MANTRA
i think
« Reply #17 on: May 24, 2003, 03:39:42 AM »
Quote
Open /includes/global.php


I think global.php in root directory V@no.

 :wink:

Thanks this was good hack

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: i think
« Reply #18 on: May 24, 2003, 03:48:06 AM »
Quote from: mantra
Quote
Open /includes/global.php


I think global.php in root directory V@no.

ooopss....u are right...wasnt pay attention on that...thx, corrected.
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 stephanesantodom

  • Pre-Newbie
  • Posts: 3
    • View Profile
[MOD] Language select
« Reply #19 on: June 16, 2003, 05:13:36 PM »
Hello,

On my  website, any of these two mods wants to run... :(   whyyyy??
who wants to help me ?  :cry:
Tanks !
Stephane.

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
[MOD] Language select
« Reply #20 on: June 16, 2003, 09:50:12 PM »
Quote from: stephanesantodom
who wants to help me ?  :cry:

I dont...:roll: unless u tell us what exactly the problem is.
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 martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Language select
« Reply #21 on: March 29, 2005, 12:14:50 AM »
wonderful feature :) Thank you V@no.

On my page the user does not stay on the "right" language if clicking on certain links - e.g.: "Delete lightbox" or any link with an extra template (in my case index.php?template=help or index.php?template=mods) and goes back to the default language :(
How could I arrange it, that the user stays on "his" language and is not sent back to default  :?:
MAяTRIX


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: [MOD] Language select
« Reply #22 on: March 29, 2005, 12:30:41 AM »
that's because these links are hard-coded into templates, you will have to parse those links through $site_sess->url(); function and then register the result as tags. or u can try add php code directly in your template:
Code: [Select]
<a href="
<?php
global $site_sess;
echo 
$site_sess->url(ROOT_PATH."index.php?template=help");
?>

">Help</a>
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 martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Language select
« Reply #23 on: March 29, 2005, 12:49:19 AM »
Fast and reliable :) Thank you again V@no! It works fine.

I'll try to figure out, how to use the $site_sess->url() function, because I don't like PHP in the template files :)
MAяTRIX


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: [MOD] Language select
« Reply #24 on: March 29, 2005, 12:57:20 AM »
u can look how its done in includes/page_header.php
just do same thing ;)
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 martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Language select
« Reply #25 on: March 29, 2005, 01:01:53 AM »
OK. TNX  :D

BTW: what about the "Clear Lightbox" link?
That's made with some javascript, asking you, if you really want to clear the lightbox... (default 4images behaviur? I don't remember I've changed that) and if the user clears the lightbox, then he's redirected to the default language too  :o
MAяTRIX


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: [MOD] Language select
« Reply #26 on: March 29, 2005, 01:03:57 AM »
I belive its in lightbox.html template...
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 martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Language select
« Reply #27 on: April 01, 2005, 12:18:26 AM »
yes it is :)

The strange thing on it is, that the url is running throught the $site_sess->url(); function, but somehow it looses the lang-attribute  :(
So: deleting lightbox causes going back to the main-language.

One more question: May I somehow save the lang-setting for the visitor - so he gets the same language when visiting the page next time (well, unless he doesn't delete his cookies) I guess I saw such a topic here on the forum, but can't re-find that
MAяTRIX


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: [MOD] Language select
« Reply #28 on: April 01, 2005, 01:36:29 AM »
One more question: May I somehow save the lang-setting for the visitor - so he gets the same language when visiting the page next time (well, unless he doesn't delete his cookies) I guess I saw such a topic here on the forum, but can't re-find that
its possible, try this:
in global.php find:
4images v1.7:
Code: [Select]
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;
  }
}

4images v1.7.x:
Code: [Select]
if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
  $requested_l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
  if ($requested_l != $config['language_dir'] && file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php')) {
    $l = $requested_l;
    $config['language_dir'] = $l;
  }
}

Replace it with:
Code: [Select]
if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
  $requested_l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
  if (!preg_match('#\.\.[\\\/]#', $requested_l) && file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php'))
  {
    if ($requested_l != $config['language_dir'])
    {
      $l = $requested_l;
    }
    $config['language_dir'] = $requested_l;
    setcookie('4images_lang', $requested_l, (time()+ 60 * 60 * 24 * 365), "/", "", 0);
  }
}
else
{
  if (isset($HTTP_COOKIE_VARS['4images_lang']) && !preg_match('#\.\.[\\\/]#', $HTTP_COOKIE_VARS['4images_lang']) && file_exists(ROOT_PATH.'lang/'.trim($HTTP_COOKIE_VARS['4images_lang']).'/main.php'))
  {
    $l = $config['language_dir'] = trim($HTTP_COOKIE_VARS['4images_lang']);
  }
}
define("LANG_URL", !(isset($HTTP_COOKIE_VARS['4images_lang']) && trim($HTTP_COOKIE_VARS['4images_lang']) == $config['language_dir']));

And if u are using version B of this mod, then replace in includes/page_header.php
Code: [Select]
    $lang_select .= "<a class=\"lang\" href=\"".$lang_url.(preg_match("/english/i",$folder) ? "" : ((preg_match("/\?/", $lang_url) ? "&" : "?")."l=".$folder))."\" onMouseOver=\"(window.status='$folder'); return true\" onMouseOut=\"window.status=''; return true\"><img src=\"".TEMPLATE_PATH."/images/".$folder.".gif\" border=\"0\" alt=\"".$folder."\"></a>&nbsp;";with this:
Code: [Select]
    $lang_select .= "<a class=\"lang\" href=\"".$lang_url.(preg_match("/\?/", $lang_url) ? "&" : "?")."l=".$folder."\" onMouseOver=\"(window.status='$folder'); return true\" onMouseOut=\"window.status=''; return true\"><img src=\"".TEMPLATE_PATH."/images/".$folder.".gif\" border=\"0\" alt=\"".$folder."\"></a>&nbsp;";
If you don't want always see l=blah in the url, then in includes/sessions.php find:
    if (!empty($l)) {

Replace it with:
    if (!empty($l) && LANG_URL) {



P.S.
I've updated the code to include the security fix
For these who installed this mod before, you'll need find and replace this block in global.php:
Code: [Select]
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'];
  }
}
« Last Edit: July 17, 2010, 12:17:51 AM 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 martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Language select
« Reply #29 on: April 01, 2005, 08:54:28 AM »
P.S. I havent test it though.

Then I will  :wink:

I'll report the results as soon as I try that out.
Thank you
MAяTRIX