Hello tarmakmedia,
the language codes are
es_AR for Argentina
ar_AE for Arab Emirates
ar_LB for Lebanon
The language code for Arabic in WordPress is just ‘ar’.
Could you please verify your setting?
Cheers,
Dennis.
Sorry you are right, I typed it the wrong way around. I have those settings, however I cannot get it to display the right flag in the back and front end. I have been looking through pages of code and even resulted to renaming the actual image files to over come this problem.
Could you perhaps point me into the direction if where to find this in your code as it seems to happen when wordpress does not specify any locale?
Thanks
There is just two cases when WordPress has no value for the language: When there is nothing set at all or when it is set to American English. Are there all languages set in their blogs?
Yes language values are set in the the blogs.
I can only think of something alone the lines of getting the language:
$lang = get_blog_option( $blog->userblog_id, 'WPLANG' );
And then forcing the flags for the culprits:
switch($lang){
case "":
$language = "EN";
$flag = "us";
break;
case "ar":
$language = "AR";
$flag = "lb";
break;
default:
$flag = strtolower( substr( $lang, -2 ) );
$language = strtoupper( substr( $lang, -2 ) );
break;
}
But this does not seem like a very efficient solution.
Are you able to reproduce this problem from your side when installing Arabic?
This would be indeed not very effective. Please have a look here:
https://github.com/lloc/Multisite-Language-Switcher/wiki
There you’ll find for example a snippet to get the language of the current blog:
$blog = MslsBlogCollection::instance()->get_current_blog();
$language = $blog->get_language();
Let me know,
Dennis.
Ok thanks for that, would you be able to point me as to which function handles the displaying of the language and the flag in the front and back end of wordpress?
Something I wanna share that could be useful to enhance the display of the blogs in the back end. It basically adds the language and the flags next to your blogs in a dropdown menu of the admin bar. Also does so instead of the dashboard. Very useful to differentiate your blogs. Repo is at: https://github.com/tarmak/Wordpress-Multisite-Simple-Custom-Admin
You can view the screenshots.
You are welcome to use and adapt any code into your plugin:
// Change the "My Sites" dropdown menu WP logos to the language flags and add the language locale at the end of the site name
if ( ! function_exists( 'simplify_add_mysites_logo' ) ) {
function simplify_add_mysites_logo() {
global $wp_admin_bar;
foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
$menu_id = 'blog-' . $blog->userblog_id;
$blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname;
if ( is_multisite( ) ) $lang = get_blog_option( $blog->userblog_id, 'WPLANG' );
else $lang = get_bloginfo( 'language' );
switch($lang){
case "":
$language = "EN";
$flag = "us";
break;
case "ar":
$language = "AR";
$flag = "lb";
break;
default:
$flag = strtolower( substr( $lang, -2 ) );
$language = strtoupper( substr( $lang, -2 ) );
break;
}
$blavatar = '<img src="' . content_url() .'/mu-plugins/simple-custom-admin/flags/' . $flag .'.png" alt="' . esc_attr__( 'Blavatar' ) . '" width="16" height="11" class="blavatar"/>';
$wp_admin_bar->add_menu( array(
'parent' => 'my-sites-list',
'id' => $menu_id,
'title' => $blavatar . $blogname . ' ' . $language ,
'href' => get_admin_url( $blog->userblog_id ) )
);
}
$wp_admin_bar->remove_node('comments');
$wp_admin_bar->remove_node('new-content');
$wp_admin_bar->remove_node('wp-logo');
if ( is_multisite( ) ) { $wp_admin_bar->remove_node('site-name'); }
$wp_admin_bar->remove_node('network-admin');
$wp_admin_bar->remove_node('wpseo-menu');
$wp_admin_bar->remove_node('search');
if ( is_super_admin( ) && is_multisite( ) ) {
$wp_admin_bar->add_menu( array(
'id' => 'network-administration',
'title' => __('Network Admin') ,
'href' => get_admin_url( 1, 'network' )
));
$wp_admin_bar->add_menu( array(
'id' => 'my-sites',
'href' => '#',
));
}
}
}
add_action( 'wp_before_admin_bar_render', 'simplify_add_mysites_logo' );
// Replace the name "Dashboard" for each site with the language
if ( ! function_exists( 'simplify_edit_admin_menus' ) ) {
function simplify_edit_admin_menus() {
global $menu;
global $userblog_id;
if ( is_multisite( ) ) { $lang = get_blog_option( $userblog_id, 'WPLANG' ); $blog_name = get_blog_option( $userblog_id, 'blogname') . " / "; }
else { $lang = get_bloginfo( 'language' ); $blog_name = get_option('blogname') . " / "; }
switch($lang) {
case "":
$flag = "us";
$language = "EN";
break;
case "ar":
$language = "AR";
$flag = "lb";
break;
default:
$flag = strtolower( substr( $lang, -2 ) );
$language = strtoupper( substr( $lang, -2 ) );
break;
}
$menu[2] = array( $blog_name . $language, 'read', 'index.php', '', 'menu-top menu-top-first', 'menu-dashboard', content_url() .'/mu-plugins/simple-custom-admin/flags/' . $flag .'.png' );
}
}
add_action( 'admin_menu', 'simplify_edit_admin_menus' );
The switcher has its own class for this: MslsOutput https://github.com/lloc/Multisite-Language-Switcher/blob/master/includes/MslsOutput.php
I will have a look on your code later. Thanks for this.