Skip to:

Different languages for different users

  • copperblade


    Here is what I was trying to get some kind of multi-language support going:

    Index: bb-includes/l10n.php


    — bb-includes/l10n.php (revision 2040)

    +++ bb-includes/l10n.php (working copy)

    @@ -2,6 +2,9 @@

    function get_locale() {

    global $locale;

    + if (isset($_GET))

    + $locale=$_GET;


    if (isset($locale))

    return $locale;

    Then I go to: and it supplies that language. Great, but of course none of the links that bbPress generates has the ?lang=en_US option set. So I guess, is there a plugin for this?

    I’m not looking for (but would be better than nothing):

    Something that lets a user set their language, and changes the language when logged in.

    I am looking for (ideal plugin):

    Something that allows multi-language support by virtue of URL location and/or variable (as above). What language you are viewing makes more sense to depend on the URL, not on your login. Especially, since forums are also useful to the public when they don’t have a login to begin with.

    Even just being able to set the language on a per-forum basis would be good, then I could just make different forums for different languages.

    I guess I can modify my theme to include “language translation” links and keep my current hack.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)

  • _ck_


    You can set a cookie and make it semi-permanent.

    Because there is also a filter in that function, you do not need to hack the core.

    $locale = apply_filters('locale', $locale);

    You would make a mini-plugin something like this

    add_filter('locale', 'language_switcher');
    function language_switcher($locale) {
    if (!empty($_REQUEST['lang'])) {$locale=substr(strip_tags(stripslashes($_REQUEST['lang'])),0,30);}
    return $locale;

    You still have to write the code to make some kind of pulldown/menu to select the language and set the cookie.

    There is a language switcher for wordpress that could be ported to bbPress, I think there was some talk about it around here and someone else made their own too.

    Oh here it is:



    I’ve now made a full plugin that uses cookies so any user can switch languages.



    Wow, thanks for that. Any specific action or filter you’d recommend I attach this to so I can insert it without modifying template code? Like the sidebar? I’m new to bbPress and I don’t know what all the plugin API’s are. If I attach it to the sidebar, do you want the code?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar