Recent Topics

Misunderstanding Localization Feature?

Started by on May 12, 2007 – Contents updated: May 12, 2007

May 12, 2007 14:49    

Maybe I do misunderstand the localization feature of b2Evolution:

I think that guest users should be displayed the menu items (e.g. "Arhcives", "Categories" etc. in the default language of their browser.

Registered users should be displayed the text in the language they have chosen in their profile.

Is this right?

In my blog I always get the text displayed in the default language of my blog. Neither the browser settings nor my profile settings are used.

Is this a bug somewhere in my installation or is it just working as designed. If the latter is the case is there a possibility to change the behaviour to the one I described above?

Thanks,
Michael

Update:

I found a solution for the first part. If you add "locale_temp_switch( locale_from_httpaccept() );" at the beginning of the _main.php you at least get the right language depending on the browser language.

So now I only need to find a solution how to change the language if the current registered user has a different langugage in his profile....

May 13, 2007 12:35

It now works for me as I wanted it to be. What did I do?

I added the following lines at the beginning of the "_main.php" (before the line "skin_content_header(); // Sets charset!"):

.........................................................

if( $current_User->locale == '')
{
$urs_language = substr(locale_from_httpaccept(),0,2);
locale_temp_switch( locale_from_httpaccept() );
}
else
{
$urs_language = substr($current_User->locale,0,2);
locale_temp_switch( $current_User->locale );
}

.........................................................

This changes the locale to the primary language of the browser (if not logged in) or to the locale of the user which is currently logged in.

I also can display different static texts (e.g. in menues etc.) depending of the users's language.

I do this e.g. with the following IF clause:

.........................................................

<?php if ($urs_language == "de")
{
// do things for german language
}
else
{
// do things for other languages
}
?>

.........................................................

Not sure if this is the best way to do it, but it works at least ....

May 13, 2007 13:07

nice..

bookmarked! :D

very useful..


Form is loading...

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