| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | Mark Forums Read | User manuals | Login |
X5 - Setting the language based on user's browser language | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
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?
__________________
Core version: 5.5.xx |
|||||||
#2
|
|||||||||
|
|||||||||
Re: X5 - Setting the language based on user's browser language
I would look in classes/XLite/View/LanguageSelector/Customer.php at method isActiveLanguage()
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
#3
|
|||||||
|
|||||||
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:
In... var/run/classes/XLite/Core/Session.php New Method: Code:
New method: Code:
Totally rewritten method... Code:
Probably could be made nicer.
__________________
Core version: 5.5.xx |
|||||||
|
#4
|
|||||||||
|
|||||||||
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 )
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|