Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Multilanguage forum

edited December 2009 in Vanilla 2.0 - 2.8
Hello,

I need to setup a multilanguage forum based on Vanilla 1, I mean a forum where any user can choose his language, and every page has a URL in each language.
I'm only talking about interface localization, not about the posts themselves.

I've installed the needed language packs.

Now I would like to be able to pass the locale in each url, so I can have (with some URL rewriting):

http://myforum.com/en/

http://myforum.com/en/comments.php?DiscussionID=1&page=1#Item_1

http://myforum.com/fr/

http://myforum.com/fr/comments.php?DiscussionID=1&page=1#Item_1

etc.

Has someone already done that? Could someone advise me on how to achieve it?

Thanks in advance.

Comments

  • Ok so I'm developing my own addon to achieve "full" multilanguage support, with by-user and category-based language management.

    I would like to know if there is a way to modify the language configuration variable, according to the user prefs, before step 4 or totally redefine it within my addon. I don't find any way (except hard-coding in init_vanilla.php) since the extensions are loaded after that.

    Could a developer answer me?
  • I'm not very into the latest versions of Vanilla, but an idea came to my mind:
    use the .htaccess file to detect the language in the url, like in the scheme you wrote above and then send the request to a .php which could load the dictionary for the appropriate language, and load the requested page afterwards
  • Thanks miquel, good idea, I'll definitely try this out.
  • It works!

    I added the following line to my .htaccess:

    RewriteRule ^(de|en|fr)(\/?)(.*)$ dispatch.php?lang=$1&url=$3 [L,QSA]

    and here is my dispatch.php:

    <?php $dispatch_lang = !empty($_GET['lang']) ? $_GET['lang'] : 'en'; $dispatch_url = !empty($_GET['url']) ? $_GET['url'] : 'index.php'; // Security check: does the file exists? $dispatch_file = basename($dispatch_url); if (!file_exists($dispatch_file)) {header('HTTP/1.0 404 Not Found'); die;} include($dispatch_url);

    Then, in conf/settings.php, I have:

    $Configuration['LANGUAGE'] = !empty($dispatch_lang) ? $dispatch_lang : 'en'; // [...] $Configuration['WEB_ROOT'] = '/'; $Configuration['BASE_URL'] = 'http://myforums.com/'.$Configuration['LANGUAGE'].'/';

    as you can see, I renamed my language folders en and fr (instead of English and French).

    Then, every time I need the current language in my code, I can use $Configuration['LANGUAGE'].
  • hello there

    i am new in vanilla.
    i want to use exactly the same as you did.
    but vanilla version 2.0.18.1 doesn't have dispatch.php
    please let me know how can i do for vanilla latest version ?

  • @nawfreda‌

    This is an old thread for vanilla 1 which is a completely different software.

    I believe there is a locale switcher on github. that would change the locale of the forum.

    You can't force people to write in a language though, if you wanted to have language sections you could use categories.

    btw pls make a new discussions if you have an questions.

    grep is your friend.

Sign In or Register to comment.