Multisite: How can I have the admin bar (toolbar) use the language of the user instead of the language of the sub-site being viewed?

Until there is a fix for it in WordPress Core you can use this ‘dirty’ way: Switch to user locale before admin bar items are processed: add_filter( ‘admin_bar_menu’, ‘ws390690_admin_bar_in_user_locale’, 10, 1 ); function ws390690_admin_bar_in_user_locale($wp_admin_bar){ switch_to_locale( get_user_locale() ); return $wp_admin_bar; } Switch back to site locale after admin bar has been rendered: add_filter( ‘wp_after_admin_bar_render’, ‘ws390690_admin_bar_in_user_locale_back’, 10, … Read more

WordPress Locale Switching on Accept-Language Header

that’s going to be a bit tricky since WordPress doesn’t relate date and time format to language. so to get the current language from the browser you can use $_SERVER[‘HTTP_ACCEPT_LANGUAGE’] and then based on that you can change the date format: function update_date_format(){ $lang = substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’], 0, 2); if (strpos($lang, ‘au’) > 0){ $date_format=”d/m/Y”; // … Read more

2 localizations inside a WordPress theme

Technically, this is possible. You can load as many language files as you want: load_theme_textdomain( ‘text_domain_1’, get_template_directory() . ‘/languages/td1’ ) ); load_theme_textdomain( ‘text_domain_2’, get_template_directory() . ‘/languages/td2’ ) ); In terms of performance it may be useful if want to separate front-end and back-end translations. But it is the wrong solution if do this to manage … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)