Recent Topics

[Hack] [1.8] Use the users http-locale instead of the blogs.

Started by on Jul 10, 2006 – Contents updated: Jul 10, 2006

Jul 10, 2006 20:05    

This hack will make the blog use the user's http-locale, instead of the default blogs.

This means that french viewers of your english blog will see translatable text in french instead of english.

It is disabled by default because what would a french user be doing reading a english blog if they can't read english in the first place.

But for some blogs, posts are written in multiple languages because the audience's language varies.

E.g. I write my post in english and french, so french users can read it and so can english users. But i also want all the default text to be translated into french as well for the french users. So i apply this hack.

Heres what you do:

[ File; /blogs/inc/_blog_main.inc.php, Line; 141-143 ]

Replace

// Activate matching locale:
$Debuglog->add( 'Activating blog locale: '.$Blog->get('locale'), 'locale' );
locale_activate( $Blog->get('locale') );


With

// Activate matching locale:
//$Debuglog->add( 'Activating blog locale: '.$Blog->get('locale'), 'locale' );
//locale_activate( $Blog->get('locale') );


Alternatively you could do something like this, so only blogs that you want to use the user's locale should, instead of all the blogs:

// If blog is [Whoevers] then use the users http locale instead of applying the following which will use the blog's default locale
if( $blog != 7 ) {
	// Activate matching locale:
	$Debuglog->add( 'Activating blog locale: '.$Blog->get('locale'), 'locale' );
	locale_activate( $Blog->get('locale') );
}

All done.

More reasoning behind why the above code is their by default can be read here;
http://forums.b2evolution.net//viewtopic.php?t=8311
and here;
http://todo.b2evolution.net/todo.php?title=locale_switching_priorities&more=1&c=1&tb=1&pb=1

Oct 28, 2006 13:19

This hack does not seem to apply any more for the 1.8.1 release....


Form is loading...

Photo gallery software – This forum is powered by b2evolution CMS, a complete engine for your website.