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.
I also tried using PHP to detect browser language, but what is the API to tell wordpress to show the correct language (e.g. screen-reader-text)? or allow a site visitor to change the language on-the-fly?
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)?