I am trying to load localization file depends on users settings. Is this way is correct or there are better ways to implement locale changing depends on user settings?
<?php
add_filter( 'locale', 'theme_localized' );
function theme_localized( )
{
if(is_user_logged_in()) {
$locale = get_user_locale();
return $locale;
}
}
?>
This code is working but I am not sure that this is the conventional way of translating website.