MOD REQUEST Lang flags

This forum is now closed as part of retiring phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

This is your full code in the function language_select:

Code: Select all

// 
// Pick a language, any language ... 
// 
//MOD Guest_language // $flags optional boolean 
function language_select($default, $select_name = "language", $dirname="language", $flags = 0) 
{ 
global $phpEx, $phpbb_root_path; 

$dir = opendir($phpbb_root_path . $dirname); 

$lang = array(); 
while ( $file = readdir($dir) ) 
{ 
if (preg_match('#^lang_#i', $file) && !is_file(@phpbb_realpath($phpbb_root_path . $dirname . '/' . $file)) && !is_link(@phpbb_realpath($phpbb_root_path . $dirname . '/' . $file))) 
{ 
$filename = trim(str_replace("lang_", "", $file)); 
$displayname = preg_replace("/^(.*?)_(.*)$/", "\\1 [ \\2 ]", $filename); 
$displayname = preg_replace("/\[(.*?)_(.*)\]/", "[ \\1 - \\2 ]", $displayname); 
$lang[$displayname] = $filename; 
} 
} 

closedir($dir); 

@asort($lang); 
@reset($lang); 

//START MOD Guest_language * Return image files with links 
if ($flags) 
{ 
while ( list($displayname, $filename) = @each($lang) ) 
{ 
$lang_select .= '&nbsp; <a href="index.php?language=' . $filename . '"> 
<img src="images/flags/languages/' . $filename . '.gif" title = "' . ucwords($displayname). '" border="none"></a>'; 
} 
} 
else 
//END MOD Guest_language * Return image files with links 
{ 
$lang_select = '<select style="width:200px;" name="' . $select_name . '">'; 
while ( list($displayname, $filename) = @each($lang) ) 
{ 
$selected = ( strtolower($default) == strtolower($filename) ) ? ' selected="selected"' : ''; 
$lang_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>'; 
} 
$lang_select .= '</select>'; 
} 
and at the end you miss

Code: Select all

return $lang_select;
}
Looks like you inadvertently removed this.
caspert_ghost
Registered User
Posts: 199
Joined: Thu Apr 21, 2005 1:58 pm
Location: China
Contact:

fatal error

Post by caspert_ghost »

Fatal error: Cannot redeclare language_select() (previously declared in /var/www/html/bbs/includes/functions_selects.php:28) in /var/www/html/bbs/includes/functions_selects.php on line 28


after adding the edit you suggested :(
caspert_ghost
Registered User
Posts: 199
Joined: Thu Apr 21, 2005 1:58 pm
Location: China
Contact:

FINALY

Post by caspert_ghost »

I finally got it up and working propperly. turned out because the original select default language was installed I forgot to rem the language_select call..
now I am just getting it to look right.

www.mjsutton.com/bbs
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: FINALY

Post by Merlin Sythove »

caspert_ghost wrote: Now I am just getting it to look right.
www.mjsutton.com/bbs


OK, good for you! And even though I may have been a bit short with you, your problems did help me to get the mod better documented :D

As for the looks: if you make the pictures the same height, the flags may align better.
caspert_ghost
Registered User
Posts: 199
Joined: Thu Apr 21, 2005 1:58 pm
Location: China
Contact:

Post by caspert_ghost »

Merlin I cannot thank you enough for the help you have given us.
if I can get this to look and work the way it is in my mind I will be a happy person.
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

You're welcome, that is what this community is about :D
walthelm
Registered User
Posts: 5
Joined: Mon May 01, 2006 7:44 pm
Contact:

Re: MOD REQUEST Lang flags

Post by walthelm »

caspert_ghost wrote: I would like a MOD that puts 2 flags in the top creating a 3rd line under profile / login/logout (centered)


Such a feature would be useful. I had the same problem, but came up with a different solution: I wrote a little mod so the you can attach a language to a session using an URI option. I.e. http://www.walthelm.net/bb/index.php?deflang=german will open a session using the German interface.

So users coming from the german pages will get a german user interface. Users from the English pages will get English. (No other languages installed, but the mod can handle up to 250 languages).

Advantage: you don't even have to choose a different language. Your native language is active immediately.

Disadvantage: if you accidentally got to the board using the wrong link, you can't change the language (unless you delete the session cookie and try again).

Details are in http://www.phpbb.com/phpBB/viewtopic.php?t=387671

Best
Axel
caspert_ghost
Registered User
Posts: 199
Joined: Thu Apr 21, 2005 1:58 pm
Location: China
Contact:

????

Post by caspert_ghost »

You have a habbit of responding to a post over a year old? This topic should have been moved to the archives after 6 months of being solved.
walthelm
Registered User
Posts: 5
Joined: Mon May 01, 2006 7:44 pm
Contact:

Post by walthelm »

Well, when you get older, a year isn't that long a time any more. (Do you consider the problem solved?)
giorgio79
Registered User
Posts: 16
Joined: Wed Oct 25, 2006 4:59 am

Re: MOD REQUEST Lang flags

Post by giorgio79 »

Hi,

Great mod, works really nice.

Has anyone modified it so that it works for logged in users as well?

Cheers
G
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: MOD REQUEST Lang flags

Post by Merlin Sythove »

Without really studying the original mod again, look at the mod instructions here:

Code: Select all

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

   if ( $userdata['user_id'] == ANONYMOUS )
And change it to

Code: Select all

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

   //if ( $userdata['user_id'] == ANONYMOUS )
(Find the corresponding line in your modified file and change that)
See if that works for you.
Need custom work done? Pimp My Forum!
giorgio79
Registered User
Posts: 16
Joined: Wed Oct 25, 2006 4:59 am

Re: MOD REQUEST Lang flags

Post by giorgio79 »

Thanks Merlin!

Worked like a charm :P
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: MOD REQUEST Lang flags

Post by Merlin Sythove »

Glad to hear it. Enjoy!
Need custom work done? Pimp My Forum!
Post Reply

Return to “[2.0.x] MOD Requests”