Info
- 2 posts
- 1 voice
- Started 3 years ago by yokima
- Latest reply from yokima
- This topic is not resolved
How to read bbPress Theme Switcher's theme user choice cookie outside of bbPress
-
- Posted 3 years ago #
Hello,
I would like to have bbPress in two languages, using the same forum DB. So when viewing in language 1, the forum's interface would be in language 1 with all the postings listed, and in language 2, the interface would be in language 2 with the same postings listed.
I plan on achieving this with bbPress theme switcher ( http://bbpress.org/plugins/topic/bbpress-theme-switcher/ ) and the link to switch between the themes/languages would be /bbpress/?bbtheme=lang1 and /bbpress/?bbtheme=lang2
I would also like to set up a php page at the root of the web domain to auto-detect and forward to the appropriate mediawiki language page based on
1) user's browser language preferences if this is a first time visit
2) last connection's languages preferences, which would be saved in the form of bbPress's theme preference cookie.with a file structure of
/blog
/blog/bbpress
/blog/wiki
/langdetect.phpMy code so far is:
?php
/* langdetect.php */$defaultlang = 'en'
$lang = $defaultlang;/* bbPress theme cookie detection */
if cookie exists {
(read cookie and set $lang to either en or ko.. bla bla)
}/* WordPress and/or MediaWiki last visit language detection */
elseif previous visit info exists {
(i'll figure this out later)
}/* detect in-browser lang pref ... modified from http://kaldung.com/en/php_detectbrowserlanguage.html */
else {
$langlist = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach($langlist as $curLang) {
$curLang = explode(';', $curLang);
/* use regular expression for language detection */
if (preg_match('/(ko|en)-?.*/', $curLang[0], $reg)) {
$lang = $reg[1];
break;
}
}
}/* redirect */
if ( $lang=='ko' ) { header( 'Location: http://ENGLISHPAGE' ) ; }
else { header( 'Location: http://ENGLISHPAGE' ) ; }?>
How can I read the bbPress cookie that contains the Theme Switcher theme preference?
-
- Posted 3 years ago #
bump?
-
You must log in to post.