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

Home » FUDforum » FUDforum Suggestions » Select theme, language by browser locale
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Select theme, language by browser locale [message #158937] Fri, 17 April 2009 13:56 Go to next message
Peter Vendike is currently offline  Peter Vendike   Denmark
Messages: 65
Registered: February 2009
Location: Denmark
Karma: 0
Member
Translator
With SMF vers. 2 you can make a installation where the language follows browser locale, so users are not forced to select theme/language in personal settings.

Would by nice to have the same in FUD, possibly as default theme.


Peter
Re: Select theme, language by browser locale [message #158954 is a reply to message #158937] Sun, 19 April 2009 17:51 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Great idea, but I don't think we will be able to push it into the 2.8.1 release. Nothing, however, stops us from exploring the possibilities and start writing a patch for it.
Re: Select theme, language by browser locale [message #159016 is a reply to message #158937] Wed, 22 April 2009 18:42 Go to previous messageGo to next message
JanRei is currently offline  JanRei   
Messages: 361
Registered: October 2005
Location: Germany
Karma: 0
Senior Member
Contributing Core Developer
Translator
I also think that this is a good idea, but this is mostly a feature for international forums with several languages.

In this context a discussion I had with Ilia comes to my mind. FUDforum sends many notifications in the language of the user triggering it (for example by posting a new message). For international forums it would probably better if the notifications would be send in the language of the recipient.
I understand that this could have an negative impact on performance and involves major changes in the code. However, it seems Frank has plans to refactor the localizations (conversion to gettext). Maybe this problem can be reconsidered in this process?
Re: Select theme, language by browser locale [message #159059 is a reply to message #158937] Thu, 30 April 2009 14:12 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
It would be pretty sweet to be able to switch theme dependant on browser - IE, if someone connects with their smartphone, they get one theme, while if they connect at home, they get another.

Re: Select theme, language by browser locale [message #159061 is a reply to message #159059] Thu, 30 April 2009 17:36 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
If we can somehow detect that it's a smartphone, it should be quite easy to implement.

Best regards.

Frank
Re: Select theme, language by browser locale [message #159062 is a reply to message #158937] Thu, 30 April 2009 23:44 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
It seems you can do it in two ways.

Either you can redirect with htaccess or directly with an apache module, so I guess one can set up a forum copy on a different folder, but connect to the same database, since I think the default/allowed themes are controlled from the GLOBALS file and not the database, right?

I found this PHP example:
<?php
$isMobile 
false;
$isBot false;

$op strtolower($_SERVER['HTTP_X_OPERAMINI_PHONE']);
$ua strtolower($_SERVER['HTTP_USER_AGENT']);
$ac strtolower($_SERVER['HTTP_ACCEPT']);
$ip $_SERVER['REMOTE_ADDR'];

$isMobile strpos($ac'application/vnd.wap.xhtml+xml') !== false
        
|| $op != ''
        
|| strpos($ua'sony') !== false 
        
|| strpos($ua'symbian') !== false 
        
|| strpos($ua'nokia') !== false 
        
|| strpos($ua'samsung') !== false 
        
|| strpos($ua'mobile') !== false
        
|| strpos($ua'windows ce') !== false
        
|| strpos($ua'epoc') !== false
        
|| strpos($ua'opera mini') !== false
        
|| strpos($ua'nitro') !== false
        
|| strpos($ua'j2me') !== false
        
|| strpos($ua'midp-') !== false
        
|| strpos($ua'cldc-') !== false
        
|| strpos($ua'netfront') !== false
        
|| strpos($ua'mot') !== false
        
|| strpos($ua'up.browser') !== false
        
|| strpos($ua'up.link') !== false
        
|| strpos($ua'audiovox') !== false
        
|| strpos($ua'blackberry') !== false
        
|| strpos($ua'ericsson,') !== false
        
|| strpos($ua'panasonic') !== false
        
|| strpos($ua'philips') !== false
        
|| strpos($ua'sanyo') !== false
        
|| strpos($ua'sharp') !== false
        
|| strpos($ua'sie-') !== false
        
|| strpos($ua'portalmmm') !== false
        
|| strpos($ua'blazer') !== false
        
|| strpos($ua'avantgo') !== false
        
|| strpos($ua'danger') !== false
        
|| strpos($ua'palm') !== false
        
|| strpos($ua'series60') !== false
        
|| strpos($ua'palmsource') !== false
        
|| strpos($ua'pocketpc') !== false
        
|| strpos($ua'smartphone') !== false
        
|| strpos($ua'rover') !== false
        
|| strpos($ua'ipaq') !== false
        
|| strpos($ua'au-mic,') !== false
        
|| strpos($ua'alcatel') !== false
        
|| strpos($ua'ericy') !== false
        
|| strpos($ua'up.link') !== false
        
|| strpos($ua'vodafone/') !== false
        
|| strpos($ua'wap1.') !== false
        
|| strpos($ua'wap2.') !== false;

        
$isBot =  $ip == '66.249.65.39' 
        
|| strpos($ua'googlebot') !== false 
        
|| strpos($ua'mediapartners') !== false 
        
|| strpos($ua'yahooysmcm') !== false 
        
|| strpos($ua'baiduspider') !== false
        
|| strpos($ua'msnbot') !== false
        
|| strpos($ua'slurp') !== false
        
|| strpos($ua'ask') !== false
        
|| strpos($ua'teoma') !== false
        
|| strpos($ua'spider') !== false 
        
|| strpos($ua'heritrix') !== false 
        
|| strpos($ua'attentio') !== false 
        
|| strpos($ua'twiceler') !== false 
        
|| strpos($ua'irlbot') !== false 
        
|| strpos($ua'fast crawler') !== false                        
        
|| strpos($ua'fastmobilecrawl') !== false 
        
|| strpos($ua'jumpbot') !== false
        
|| strpos($ua'googlebot-mobile') !== false
        
|| strpos($ua'yahooseeker') !== false
        
|| strpos($ua'motionbot') !== false
        
|| strpos($ua'mediobot') !== false
        
|| strpos($ua'chtml generic') !== false
        
|| strpos($ua'nokia6230i/. fast crawler') !== false;
?>


So, basically, in the theme manager, you can get an option to set also the mobile default theme as well as the regular default theme.

I don't think it should require all too much work to add the functionality, although for sure it will be annoying to make a theme for the mobile, but that is a later headache hehe.

Of course, if there is no real need for such a function in the community, I guess I can tweak myself, but with the increasing mobile browsing market, I think it could be pretty cool.


Re: Select theme, language by browser locale [message #159078 is a reply to message #159062] Sat, 02 May 2009 19:05 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
We can add a INITUSER call-out to the code. That will allow users can write simple plugins to select themes based on whatever they fancy: language, browser, etc.

Any volunteers to help us create a "lo-fi" theme?
Re: Select theme, language by browser locale [message #159079 is a reply to message #159078] Sat, 02 May 2009 20:50 Go to previous messageGo to next message
kerryg is currently offline  kerryg   Canada
Messages: 157
Registered: September 2008
Karma: 0
Senior Member
How do you mean "lo-fi"? Low bandwidth for phones? I'll help if I can.

[Updated on: Sat, 02 May 2009 20:50]

Report message to a moderator

Re: Select theme, language by browser locale [message #159086 is a reply to message #159079] Sun, 03 May 2009 05:59 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Yes, a Lo-Fi theme is basically a light version of the forum with minimal formatting that people can use on devices with smaller screens.
Re: Select theme, language by browser locale [message #159391 is a reply to message #159086] Fri, 29 May 2009 17:16 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Here is a simple plugin that can be extended to route users to different themes. Please extend and post back:

theme_router.plugin
// Initialize plugin
plugin_add_hook('INITUSER', 'plugin_theme_router');

// Override theme path
function plugin_theme_router($usr) {
    if (...) {
	@define('fud_theme', 'theme/mobile/');
    }
}
Re: Select theme, language by browser locale [message #159392 is a reply to message #158937] Fri, 29 May 2009 18:09 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
I will have to patch up to plugin support and then i will revisit this. Will take a while since I have to do it all by hand.

Re: Select theme, language by browser locale [message #159393 is a reply to message #159392] Fri, 29 May 2009 18:23 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Thanks David!

I've started to document this plugin at http://cvs.prohost.org/index.php/Theme_router.plugin

BTW: Theme support (including the INITUSER hook) is available with FUDforum 2.8.1.
Odp: Re: Select theme, language by browser locale [message #186979 is a reply to message #159393] Thu, 08 October 2015 09:01 Go to previous message
sp9auv is currently offline  sp9auv   United Kingdom
Messages: 2
Registered: October 2015
Location: Gliwice
Karma: 0
Junior Member
First you must go to the Administration - then choice Plugin Manager
Then appears at bottom all plugin what will be available .
Choice there plugin Theme Router . And the end choice Save Configuration
Then when anybody what go to your forum Fudforum will be see
page in own langugae , what have set as the first language in a browser

sp9auv
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Get a FUDforum cloud instance in less than 30 seconds.
Next Topic: tapatalk - do you heard about it?
Goto Forum:
  

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

Current Time: Sat Nov 23 09:47:50 GMT 2024

Total time taken to generate the page: 0.02358 seconds