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.

How to create a language switch button ?

edited November 2011 in Vanilla 2.0 - 2.8
Hi everybody,
I would like to create a button to switch between french and english (two locales). The purpose is to allow all visitors to see the website in their language.
I've tried to overwrite the values of

$Configuration['EnabledLocales']['French']
$Configuration['Garden']['Locale']
but it doesn't seems to work correctly...
Is there a plug in to do this ?
Thanks a lot !

Best Answer

Answers

  • x00x00 MVP
    edited November 2011
            $Locale = 'Locale Name';
    setlocale(LC_ALL, $Locale);
    $Gdn_Locale = new Gdn_Locale(
    $Locale,
    Gdn::ApplicationManager()->EnabledApplicationFolders(),
    Gdn::PluginManager()->EnabledPluginFolders()
    );
    Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', NULL, Gdn::FactorySingleton, $Gdn_Locale);
    unset($Gdn_Locale);
    You need to hook early like the dispatcher. Save the locale using sessions or user meta.

    grep is your friend.

  • LincLinc Detroit Admin
    Funny you should mention this. I'm writing a plugin to do this for a client right now.
  • LincLinc Detroit Admin
    Answer ✓
    I'll probably release it officially next week, but you can grab it over here if you want to help test it: https://github.com/vanillaforums/Addons/tree/master/plugins/Multilingual
  • Ok thanks ! I'm trying all this right now ! ^^
  • edited November 2011
    @Lincoln: Good job, pal ! The links works well... thanks

    some bugs (?) :
    ?locale= doesn't works ( maybe because of url rewritng)
    the method doesn't works either.
  • You saved me a lot of time... ;)
  • I'll wait for the final plug in to be live. Thanks!
  • edit of this morning : the script method, doesn't works. ^^
  • I was looking for this add-on all day and finally found .. Thank you very much for your work.

  • @Lincoln I just downloaded your "Multilingual" plugin but after installing it and enabling it, when I click on a language to switch, it doesn't work - i.e. just reload the same page in the default language.

    I'm using "Version 2.0.18.1" of Vanilla Forums.

    Concerning the locales, I downloaded them from http://vanillaforums.org/addon

    Thanks in advance for a short feedback.

  • LincLinc Detroit Admin

    Multilingual may not work in 2.0.18.1. I may have made alterations to core to accomodate it, so you'd need to use an "unstable" version or wait for 2.1.

  • edited January 2012

    Hey, as said above your plugin indeed does not work with 2.0.18.1, i installed it (edited the file so it would allow me to install), it successfully installed and enabled plugin and the language switcher appeared on the bottom of the page, however switching languages doesn't work. Just nothing happens. Anyway we can expect a fix soon enough or maybe i am doing something wrong?

    For all those experiencing problems, plugin works fine with this version.

  • Hi @Lincoln,

    Could you point me the specified "unstable" version that I could use and maybe improve/fix by myself please? A link to github should be enough ;-)

    I really hope to see this plugin either part of the vanilla core, or else released with backward compatibility!

    Thanks in advance for a short feedback!

Sign In or Register to comment.