Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

LanguageSelector: a new extension for versatile user language selection

Max_BMax_B New
edited August 2006 in Vanilla 1.0 Help
There were already ChooseLanguage by Jonas John.

But I wanted something more versatile. This one add two main features:
- The language is automatically selected from the browser HTTP_ACCEPT_LANGUAGE information.
- Registered users can save their setting from a new panel in the account section.

There is also, as in ChooseLanguage, a select in the control panel for unregistered users.

It save the selected language value in a server side SESSION variable rather than in a cookie.
Remember this while testing, you should close the Vanilla session or the browser to reset the variable and test automatic selection.

*********
NOTES
*********
1 - The language setting for registerd user is stored accros session in the standard Vanilla Attributes column of the Users table. Thus, the setting is visible, and editable from the Identitity from. If the label of this attribute is changed, the setting becomes inoperant. The extension then fallback to browser language selection, or else default to global forum language setting.

2 - A side effect of this extension can be confusing: any user able to change the global forum language, when opening the standard form, will be presented a default selection of his own personal language setting, even if this is not the current setting.
Example: the forum is set up to English, the administrative user set its own preference to Spanish. When he displays the form, he'll see Spanish selected forum-wide, even if English is currently in use.
This is only when administrator saves the form that the language will be changed application-wide.
Ultimately, look at conf/settings.php to check the global setting.

3 - This is not a "pure" extension. Due to the order of execution we need to insert some processing before the language files inclusion.

Edit:
4 - Any languages/definitions.php dictionary file MUST include a line defining the 'XMLLang' entry: $Context->Dictionary['XMLLang'] = 'en-ca';
This line is used to correlate the language codes used by browser and the name of the language directorie which are not standard in Vanilla installation. If a file does not contain this line, the language is still selectable with form selects but is not automatically choosen.

Comments

  • You should add PHP5 to the requirements. Are there any functions besides scandir that I'd have to modify in order to make this work with PHP4?
  • Update: I edited the opening comment (and readme.txt) to add the 4'th note I forgotten in the first upload.

    @kari: yeah, I didn't check well for version compat. I'll do it tomorrow.
  • Max_BMax_B New
    edited August 2006
    Uploaded a new 1.0.1 zip file to remove PHP5 dependency (hope there is no other, I have no PHP4 on my test server) and .svn hidden folder.
  • I would VERY MUCH like to have this functionality in my forum. I am, however, a bit hesitant about going into the Vanilla core files, and making alterations to the code - as it seems to be necessary with this extension. My hesitation comes from the fact that it seems to me that if an extension needs to alter the core, then every time Vanilla gets updated, I will have to go in and make alterations to the core again. Further to that, because I am not an extension developer myself, I will depend on the availability of the developer, to give me instructions I will need to go in there and make the changes. So, my question is: is there any way WHATSOEVER of doing what this extension does, without making those alterations to the core files? Mark, are you listening? - maybe you could shed some light... Multi-lingual capability is really essential in the internet...
  • @icouto
    You can bet that if I had to add this line in some core files, this is because I see no way at the moment to do it otherwise.
    I guess Mark will give us a hook someday, but I'm not sure he got this point that some of us really need multi-lingual capability on the same server. Not only global application change. Besause, after all, it's not big deal to do. One more configuration variable and a line here and there.
  • Well, afterwhile, I'm thinking about a possible solution, coming from an answer from Mark on Dev forum:

    IF
    - you don't use conf/language.php for translation, and you shouldn't if you want to be multilingual, rather keeping extensions translation in languages/*/definitions.php.
    - you accept a less efficient dictionnary loading because you will do it twice for each page
    THEN
    - copy the content of the LanguageSelector.php file of the extension into conf/language.php (or move/rename)
    - add, at the end of this file the following line : include($Configuration['LANGUAGES_PATH'].$Configuration['LANGUAGE'].'/definitions.php');This last line is a copy of the original include, so it is done a second time, overloading the default language.

    I do not promote this solution because this is not the intended purpose of conf/language.php, but it might fulfill your requirement.
  • @Max_B: thank you so much for your thoughtful response, and your willingness to provide us with a workaround! I hope that Mark will indeed provide us with a 'hook', as you say, that will enable you to do it more easily, and efficiently in the future. Being able to support multiple languages simultaneously is certainly important these days. My Forum is for Esperantists, so it is important for me to be able to easily translate Vanilla into Esperanto, and this is one of the reasons why I picked it over other forum solutions. The vast majority of Esperantists who come to the site, however, are *beginners* - which means that an entire interface in Esperanto would be, to say the least, intimidating. Many of our forum attendees are from a specific nationality (Australian), and therefore speak a specific language (English), but the truth is that we DO want to *attract* and cater to a wider range of people. This is what makes learning Esperanto so interesting in the first place: it gives you access to people in over 100 different countries straight awasy. But in order to be able to attract all those beginning Esperantists from all those different countries, we need to be able to give individual users the ability to choose their own preferred language... So, please, keep up the good work. Both you and Mark are doing something wonderful, and your programming efforts are helping bring a lot of people together, and bridge the cultural differences in an increasingly smaller world! :)
  • icouto wrote
    So, please, keep up the good work. Both you and Mark are doing something wonderful, and your programming efforts are helping bring a lot of people together, and bridge the cultural differences in an increasingly smaller world! :)
    Well, this is more compliment that my modest contribution to this sowtware deserve. But cool…
This discussion has been closed.