mdfw
2 years agoGenius
Set the visitor UI language automatically
Background:
- Our instance supports 8 different languages for the user interface.
- Our CDN/Reverse Proxy detects a user's location and can set a user's language based on that. It will, at a minimum, set a cookie.
- In the past, in the page.init, we would detect if the cookie language was different than the session language and and return a redirect while adding the "?profile.language=xx" parameter. Unfortunately, this caused significant delays for users in China because of the extra round trip.
- Currently our CDN/reverse proxy rewrites all URLs as they pass through, adding the profile.language parameter to *every* page load. This causes some odd side-effects, especially in the admin panel. It's also very challenging to debug when something is off.
Does anyone know the recommended approach to making sure that a user (including anonymous users) gets the Khoros page UI in their translated language? Our CDN/reverse proxy does place a cookie that we can read or it could deliver a special header. I imagine we could read this in page.init, but I don't see anywhere in the docs where we can tell the session to switch languages.
This all gives hints:
- This seems to give some suggestion: https://developer.khoros.com/khoroscommunitydevdocs/reference/requestlang
- Which leans to info about page.init.
- Which I think leads me to the http.session: https://developer.khoros.com/khoroscommunitydevdocs/reference/httpsession-1
- But, what's the attribute that needs setting? Is it "lang"? If anyone has a list of session attributes, that could be helpful.
Other related threads I have read:
- https://community.khoros.com/t5/Khoros-Community-Product/How-can-users-be-directed-to-a-localized-community-based-on/m-p/564967
- https://community.khoros.com/t5/Khoros-Community-Product/Launching-a-new-language-language-functionality/m-p/610975
Thanks!
Mark