Hi guys,
I was advised to ask that question here rather than in general, so here it is :
I detect the default language from the user browser. Let's say that user is not loggedin, I don't know anything about him.
I'd like to display the page in the language retrieved from the browser.
What I have now :
- a multi-language homepage : displaying french (the default language) if user goes to www.website.com/ or english if user goes to www.website.com/en
-> I'm using multi-language fields for that.
I'm able to use translatable strings also, such as :
echo __("My text to translate");
It works when I switch the url "/" to "/en" for example.
I'd like to do that without manual intervention :
- detect the browser's language
- load the right version of the homepage (User not loggedin, never seen him before scenario).
I know how to do it with multi-language :
$page->of(false); // turn off outputFormatting (if it's not already)
$lg_id = $languages->get('en'); // get the language we want
$body = $page->body->getLanguageValue($lg_id); // get the unformatted value in english
Is there a similar way to do it with translatable strings ?
Thanks