X5 - Setting the language based on user's browser language
In x4 I had some code that identified the user's language preference (using weighted values) and then displayed the site in the closest language possible with English as the default.
I did this by adding code before the get_language.php include that followed the logic below to set the store language. 1) Check user is not a robot and hasn't previously chosen a language 2) Set language based on browser setting and available languages The user could set their language to override the auto detect using a cookie that lasted a year. I want to do this in x5 but I can't work out which class/method to override so I can add in my extra detection code. Any pointers? |
Re: X5 - Setting the language based on user's browser language
I would look in classes/XLite/View/LanguageSelector/Customer.php at method isActiveLanguage()
|
Re: X5 - Setting the language based on user's browser language
I think I have this working. It's just hacks to files in var/ at the moment.
In var/run/classes/XLite/Controller/AControllerAbstract.php Code:
protected function doActionChangeLanguage() In... var/run/classes/XLite/Core/Session.php New Method: Code:
/** New method: Code:
/** Totally rewritten method... Code:
/** Probably could be made nicer. |
Re: X5 - Setting the language based on user's browser language
Good job!
You are to wrap up your changes as a custom module as all changes to files in the var/ directory will disappear once you upgrade to a newer version, install a new module, or just run the redeploy routine. You will be able to re-use the module for other X-Cart 5 stores and even list it at http://www.x-cart.com/extensions/addons (if you want :-)) |
All times are GMT -8. The time now is 07:33 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.