Change locale by detecting viewer’s browser language setting and let them choose prefered language after

I am coming from a multi-linguo country, and viewers may speak different language.

I am writing a theme and I noticed that the language of my theme only changed based on the setting of my admin panel, which mean only logged-in user or admin can do so.

What if I wanted to do it automatically by detecting user browser preference? I am using Jquery to achieve some of this function but thinking it not the right way.

What I was doing is use jquery to set initial language by browser locale, and allow user to change it with press of a button, then save the setting to cookie.

is there a “cleaner” way of doing it in wordpress using i18n on server side(while detecting browser setup and then letting viewers to change the language preference)?

Read more here:: Change locale by detecting viewer’s browser language setting and let them choose prefered language after

Leave a Reply

Your email address will not be published. Required fields are marked *