Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: emanuele on May 06, 2012, 05:36:34 PM

Title: [MOD] Browser Language Detection and Loading
Post by: emanuele on May 06, 2012, 05:36:34 PM
From now I will distribute all my mods as attachments to topics in this board.
Feel free to consider them eternal betas.

Another simple mod that recognize the default language set in the browser, check if this language exists in your SMF installation and if the user is a guest and doesn't have already another language set (in session) load this as default language.

Nothing to set, nothing to translate, nothing to edit.

Compatibility: SMF 2.0.x

https://github.com/emanuele45/Browser-Language-Detection-and-Loading

Removed because broken
Title: Re: [MOD] Browser Language Detection and Loading
Post by: Ninja ZX-10RR on April 27, 2014, 06:47:59 PM
Questa mod è stata ben poco considerata ma direi che almeno per il mio forum è ottima, mi serviva proprio :D la scritta in italiano perchè so che lo sei pure tu ^^ e grazie per la mod!

This mod has not been considered very much but at least for my forum is awesome, i really needed it :D thanks!
Title: Re: [MOD] Browser Language Detection and Loading
Post by: 4Kstore on April 28, 2014, 05:32:33 PM
Thanks man!
Title: Re: [MOD] Browser Language Detection and Loading
Post by: emanuele on April 29, 2014, 08:53:36 AM
Thanks.

Well, it's just a small mod done basically for fun... :P
Glad it can be of any help! ;D
Title: Re: [MOD] Browser Language Detection and Loading
Post by: Ninja ZX-10RR on April 30, 2014, 08:47:35 AM
I'll say that in English so if anyone experiences the same problem he would be able to understand what's wrong...
I randomly get the error in the attachments spamming my error log...
I'll attach the guilty file as well.
Please help T.T
[EDIT]Almost forgot. It's not actually a random guest who has produced the error, it was me  :o and i was logged in O.o
Title: Re: [MOD] Browser Language Detection and Loading
Post by: emanuele on April 30, 2014, 02:39:19 PM
Out of curiosity, what browser are you using?
Honestly I'm not that familiar with HTTP_ACCEPT_LANGUAGE, so I can just guess it is not always set.
So, the easiest fix is to change line 94 from:
Code (find) Select
$browser_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
to:
Code (replace with) Select
$browser_langs = !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) : array();
Title: Re: [MOD] Browser Language Detection and Loading
Post by: Ninja ZX-10RR on April 30, 2014, 04:52:57 PM
I'm using Maxthon, a light and fast browser using stuff from both Firefox and based on Chrome, with more functions and less annoying than that xD
If you want to give it a try you can find it here, i just love it: Maxthon website (http://it.maxthon.com/) the link is for the Italian language as you are Italian as well :P for anyone else you can change its language in that very same page with a button in the lower part of the page. It will be featuring also a pay-to-use thing so the more you use it and the best gifts you will receive, somehow like Blurum if you know.
Anyway thanks a lot for the fix i'll try it and see if that works :D (it should for the little coding i know it should, i'll ask again if it doesn't ;) )