FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » ...force the forum to display in another language/theme?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
icon5.gif  ...force the forum to display in another language/theme? [message #9023] Fri, 07 March 2003 15:52 Go to next message
StarLight{PL} is currently offline  StarLight{PL}   Poland
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 Wink ). So far I've tried passing a parameter (f_en [like "force_english Wink "]) 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 Wink ) 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}
Re: ...force the forum to display in another language/theme? [message #9103 is a reply to message #9023] Thu, 13 March 2003 14:49 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Don't hack the code Wink Make the theme that uses the english locale the 'default' theme, so that all users who are not registered see that theme. Once they choose to register then they can pick to remain in English theme or to pick the Polish one.

FUDforum Core Developer
Odp:...force the forum to display in another language/theme? [message #9125 is a reply to message #9023] Thu, 13 March 2003 15:14 Go to previous messageGo to next message
StarLight   Poland
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!!" Laughing

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... Very Happy

TIA

regards,
StarLight

[Updated on: Thu, 13 March 2003 15:15]

Report message to a moderator

Re: Odp:...force the forum to display in another language/theme? [message #9128 is a reply to message #9125] Thu, 13 March 2003 15:18 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You can set a cookie and then modify users.inc.t (user init code) to use the value of that cookie to choose the language for non-registered users.

FUDforum Core Developer
icon3.gif  Browser language detection hack :D [message #9222 is a reply to message #9128] Mon, 17 March 2003 14:41 Go to previous message
StarLight{PL} is currently offline  StarLight{PL}   Poland
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}
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to change the header and footer in FUDForum
Next Topic: rating column
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Oct 02 12:21:08 GMT 2024

Total time taken to generate the page: 0.04019 seconds