/*This is not my code, I really did not find the source..but here is what you are looking for…in functions.php in template*/
function my_bogo_language_switcher_links( $args = ” ) {
global $wp_query;
$args = wp_parse_args( $args, array() );
$locale = get_locale();
$available_languages = bogo_available_languages( array(
‘exclude_enus_if_inactive’ => true ) );
$translations = array();
$is_singular = false;
if ( is_singular() || ! empty( $wp_query->is_posts_page ) ) {
$translations = bogo_get_post_translations( get_queried_object_id() );
$is_singular = true;
}
$links = array();
foreach ( $available_languages as $code => $name ) {
$re_name = ”;
if($code === ‘en_US’){
$re_name = ‘Eng’;//RENAME FOR ENGLISH
}elseif($code === ‘es_ES’){ //ANOTHER LENGUAGE
$re_name = ‘Esp’;//RENAME
}else{
$re_name = bogo_get_language_native_name($code);
}
$link = array(
‘locale’ => $code,
‘lang’ => bogo_language_tag( $code ),
‘title’ => $name,
‘native_name’ => $re_name,
‘href’ => ” );
if ( $is_singular ) {
if ( $locale != $code
&& ! empty( $translations[$code] )
&& ‘publish’ == get_post_status( $translations[$code] ) ) {
$link[‘href’] = get_permalink( $translations[$code] );
}
} else {
if ( $locale != $code ) {
$link[‘href’] = bogo_url( null, $code );
}
}
$links[] = $link;
}
return apply_filters( ‘my_bogo_language_switcher_links’, $links, $args );
}
add_action(‘bogo_language_switcher_links’,’my_bogo_language_switcher_links’,100);
-
This reply was modified 7 years, 2 months ago by jorgelondo.