...force the forum to display in another language/theme? [message #9023] |
Fri, 07 March 2003 15:52 |
StarLight{PL}
Messages: 22 Registered: March 2003
Karma: 0
|
Junior Member |
|
|
Hello,
I've installed 2.3.7, and I have the following problem.
My forum is, by default, in Polish language. But, our site is in 2 languages - for now it's Polish and English, may happen there will be more.
Now, what I need is a way to force the forum, when the unregistered user enters the forum from the english pages, to display forum's english interface instead of polish (it could be a bit difficult for non-polish-speaking user to register and change the theme to english ). So far I've tried passing a parameter (f_en [like "force_english "]) in URL, modified the [include directory]/src/root_index.php.t, like this:
<?php if ( !$usr->theme ) if (!isset ($GLOBALS[f_en])) $r = q("SELECT * FROM {SQL_TABLE_PREFIX}themes WHERE t_default='Y'"); else $r = q("SELECT * FROM {SQL_TABLE_PREFIX}themes WHERE name='[english_theme_name_here]'"); //end else else $r = q("SELECT * FROM {SQL_TABLE_PREFIX}themes WHERE id=".$usr->theme); ?>
rebuilt and when I tried to pass the &f_en=1 attribute it indeed used the english interface, but all the links were still pointing to polish language version.
Is there a way (or a path which I may follow ) to enforce the theme so the links would point to their english, not polish counterparts, without adding the f_en to all links? I've noticed it sets up a session, maybe I can store it there? I'm a bit confused about the way things are built in main index. Could anyone point me in the right direction?
TIA,
StarLight{PL}
|
|
|
|
Odp:...force the forum to display in another language/theme? [message #9125 is a reply to message #9023] |
Thu, 13 March 2003 15:14 |
StarLight
Messages: 1 Registered: January 2003
Karma: 0
|
Junior Member |
|
|
I wish it was THAT easy, but I'm afraid my management will say "THAT IS NOT AN OPTION, YOU IT-WORM!! MAKE IT POSSIBLE!!"
What I need is a little hack that will allow me to switch the themes... either via passing the parameter, or saving some session variables. It only needs to be active in "unregistered" mode... As I've written, I'm (yet) unable to track where the links are built. I may hack my way to it, but, as the creator of this system You have much advanced knowledge over the system structure than I and can save me a lot of fuss during the patching...
TIA
regards,
StarLight
[Updated on: Thu, 13 March 2003 15:15] Report message to a moderator
|
|
|
|
Browser language detection hack :D [message #9222 is a reply to message #9128] |
Mon, 17 March 2003 14:41 |
StarLight{PL}
Messages: 22 Registered: March 2003
Karma: 0
|
Junior Member |
|
|
Hello,
First of all, thanks for replying so soon - it was of great help. I've developed a small hack together with a colleague - this hack allows for choosing a language based on user's browser ACCEPT_LANGUAGE settings.
in root_index.php.t, around line 28:
<?php if ( !$usr->theme ) if (!isset($GLOBALS['forcedTheme'])) $r = q("SELECT * FROM {SQL_TABLE_PREFIX}themes WHERE t_default='Y'"); else { $fthme = $GLOBALS['forcedTheme']; $r = q("SELECT * FROM {SQL_TABLE_PREFIX}themes WHERE name='$fthme'"); } else $r = q("SELECT * FROM {SQL_TABLE_PREFIX}themes WHERE id=".$usr->theme);
?>
in users.inc.t, around line 187 find this code:
<?php $rv[1] = NULL; if( !empty($GLOBALS["rid"]) && empty($GLOBALS["HTTP_COOKIE_VARS"]["frm_referer_id"]) ) set_referer_cookie($GLOBALS["r?>
(... cut ...)
and insert this below:
<?php
/*** SLT & JD: HACK => forcing another theme when unregistered ***/
preg_match_all('|(\w\w)(-\w\w)?|', $GLOBALS['HTTP_ACCEPT_LANGUAGE'], $tmp_langs); foreach($tmp_langs[1] as $tmp_lang) if(in_array($tmp_lang, array('en','pl'))) { $redir_lang = $tmp_lang; break; } unset($tmp_langs,$tmp_lang); if($redir_lang=='en') $GLOBALS['forcedTheme']='english_version';
/*** /HACK ***/ } ?>
This code sets the 'english_version' theme based on the user's browser ACCEPT LANGUAGE header. The routine sets the first of allowed languages (array('en','pl')) found in the $redir_lang variable. If the first found is en-xx (the regexp cuts the -xx variations, leaving 'en' only) then forcedTheme is set and forum opens in that theme, if not, it falls back to default.
This code is only a hack, perhaps there is more elegant way to do it, but it should be easy to modify it to select "unregistered theme" according to user browser's settings.
Thanks again!
StarLight{PL}
|
|
|