Your ultimate PunBB resource!
You are not logged in.
## ## ## Mod title: Guest language change ## ## Mod version: 1 ## Works on PunBB: 1.2.x ## Release date: 2008-06-22 ## Author: Q. Dinar (qdinar@gmail.com) ## ## Description: Ability for guests to change the board language ## ## Affected files: header.php ## include/functions.php ## style/imports/base.css ## style/imports/Cobalt_cs.css ## style/imports/Sulfur_cs.css ## style/imports/Radium_cs.css ## style/imports/Oxygen_cs.css ## style/imports/Mercury_cs.css ## style/imports/Lithium_cs.css ## ## DISCLAIMER: Please note that "mods" are not officially supported by ## PunBB. Installation of this modification is done at your ## own risk. Backup your forum database and any and all ## applicable files before proceeding. ## ##
Offline
#
#---------[ 1. OPEN ]---------------------------------------------------------
#
header.php
#
#---------[ 2. FIND (line: 163) ]---------------------------------------------
#
// START SUBST - <pun_navlinks>
$tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
#
#---------[ 3. REPLACE WITH ]---------------------------------------------------------
#
//MOD change language begin
//(there is part of code from profile.php)
$languages = array();
$d = dir(PUN_ROOT.'lang');
while (($entry = $d->read()) !== false)
{
if ($entry != '.' && $entry != '..' && is_dir(PUN_ROOT.'lang/'.$entry) && file_exists(PUN_ROOT.'lang/'.$entry.'/common.php'))
$languages[] = $entry;
}
$d->close();
// Only display the language selection box if there's more than one language available
if (count($languages) > 1 && $pun_user['is_guest'])
{
natsort($languages);
$language_selector="<select id=\"mod_guest_language\" name=\"guest_language\""
." onchange=\"var date=new Date();"
."date.setTime(date.getTime()+(365*24*60*60*1000));"
."document.cookie='punbb_guest_language='+this.value+'; expires='+date.toGMTString()+';';"
."document.location.reload(true);\""
.">";
$cookie_language=isset($_COOKIE['punbb_guest_language'])?$_COOKIE['punbb_guest_language']:$pun_config['o_default_lang'];
while (list(, $temp) = @each($languages))
{
if ($cookie_language == $temp)
$language_selector.='<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n";
else
$language_selector.='<option value="'.$temp.'">'.$temp.'</option>'."\n";
}
$language_selector.='</select>';
}
$tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'.$language_selector."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
//MOD change language end
//$tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
#
#---------[ 4. OPEN ]---------------------------------------------------------
#
include/functions.php
#
#---------[ 5. FIND (line: 155, second find) ]-----------------------------------------
#
$pun_user['language'] = $pun_config['o_default_lang'];
#
#---------[ 6. REPLACE WITH ]---------------------------------------------------------
#
//$pun_user['language'] = $pun_config['o_default_lang'];
//MOD change language begin
$pun_user['language'] = isset($_COOKIE['punbb_guest_language'])?$_COOKIE['punbb_guest_language']:$pun_config['o_default_lang'];
//MOD change language end
#
#---------[ 7. OPEN ]---------------------------------------------------------
#
style/imports/base.css
#
#---------[ 8. FIND (line: 34) ]-------------------------------------------------
#
/* 2.2 Overflow settings for posts */
DIV.blockpost DIV.box, DIV.postleft, DIV.postsignature, DIV.postmsg {OVERFLOW: hidden}
/****************************************************************/
/* 3. BUG FIXES - VERY IMPORTANT - DO NOT CHANGE */
#
#---------[ 9. REPLACE WITH ]---------------------------------------------------------
#
/* 2.2 Overflow settings for posts */
DIV.blockpost DIV.box, DIV.postleft, DIV.postsignature, DIV.postmsg {OVERFLOW: hidden}
/*mod_guest_language*/
#mod_guest_language {float:right;}
/****************************************************************/
/* 3. BUG FIXES - VERY IMPORTANT - DO NOT CHANGE */
#
#---------[ 10. OPEN ]---------------------------------------------------------
#
style/imports/Cobalt_cs.css
#
#---------[ 11. FIND (line: 23) ]-------------------------------------------------
#
.pun H2, #brdmenu {BACKGROUND-COLOR: #
#
#---------[ 12. REPLACE WITH ]---------------------------------------------------------
#
.pun H2, #brdmenu, #mod_guest_language {BACKGROUND-COLOR: #
#
#---------[ 13. OPEN]------------------------------
#
style/imports/Sulfur_cs.css
style/imports/Radium_cs.css
style/imports/Oxygen_cs.css
style/imports/Mercury_cs.css
style/imports/Lithium_cs.css
#
#---------[ 14. DO STEPS 11,12 with each]------------------------------
#
style/imports/Sulfur_cs.css
style/imports/Radium_cs.css
style/imports/Oxygen_cs.css
style/imports/Mercury_cs.css
style/imports/Lithium_cs.css
#
#---------[ 15. SAVE/UPLOAD ]-------------------------------------------------
#
Offline
you can see demo on http://tmforum.awardspace.com/
Offline
see also http://www.punres.org/viewtopic.php?id=4876 "multilanguage forum names"
related topic: http://punbb.informer.com/forums/topic/ … uage-pack/ "tatar languahe pack"
Offline
i have forgot to write to readme.txt that border of that language switcher is 0 (width):
write:
#mod_guest_language {BORDER: 0px;}
before
/****************************************************************/
/* 5. VERTICAL AND PAGE SPACING */
/
in /style/Cobalt.css and others (in that folder).
Offline