Support » Plugin: Bogo » how to change language names in language switcher?

  • LIMX

    (@limx)


    hi,

    i’m new to bogo and i absolutely love it 🙂

    one thing i have not found out but really need to do: how can i change the names of the languages shown in the language switcher?

    e.g. it shows “English (United States)” and i want it to show “ENGLISH”.

    thanks for any help,

    silke

    • This topic was modified 4 years ago by .
Viewing 2 replies - 1 through 2 (of 2 total)
  • jorgelondo

    (@jorgelondo)

    /*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 4 years ago by jorgelondo.
    Thread Starter LIMX

    (@limx)

    😀 … after looking for the source for hours i already thought about doing it like this, but would have prefered a “cleaner” way.

    anyway, thanks a lot for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to change language names in language switcher?’ is closed to new replies.