Skip to main content
fixed typo
Source Link
Mayeenul Islam
  • 12.9k
  • 21
  • 85
  • 169

I want to change the Theme's interface language without making multisite by passing langauage parameter into the URL.

<a href="<?php echo home_url('/')?lang=bn ?>">Bengali</a>

My thought is to use the following code:

if(get_query_var('bn')) {

    /**
     * CHANGE THE 'WPLANG' IN wp-config.php TO bn_BD ON THEME SWITCHING
     * Thanks: toscho
     * Source: http://wordpress.stackexchange.com/a/121136/22728
     * -------------------------------------------------- */
    
    add_filter( 'locale', 'toscho_change_language' );
    
    function toscho_change_language( $locale ) {
        return 'bn_BD';
    }

}

With checking isset() of the parameter in URL, loading of this code block. And using the theme's language file bn_BD.

But I'm actually curious about the logical proceedings:

  • Is this concept Ok?
  • Will it load the theme's language file successfully?

I want to change the Theme's interface language without making multisite by passing langauage parameter into the URL.

<a href="<?php echo home_url('/')?lang=bn ?>">Bengali</a>

My thought is to use the following code:

get_query_var('bn') {

    /**
     * CHANGE THE 'WPLANG' IN wp-config.php TO bn_BD ON THEME SWITCHING
     * Thanks: toscho
     * Source: http://wordpress.stackexchange.com/a/121136/22728
     * -------------------------------------------------- */
    
    add_filter( 'locale', 'toscho_change_language' );
    
    function toscho_change_language( $locale ) {
        return 'bn_BD';
    }

}

With checking isset() of the parameter in URL, loading of this code block. And using the theme's language file bn_BD.

But I'm actually curious about the logical proceedings:

  • Is this concept Ok?
  • Will it load the theme's language file successfully?

I want to change the Theme's interface language without making multisite by passing langauage parameter into the URL.

<a href="<?php echo home_url('/')?lang=bn ?>">Bengali</a>

My thought is to use the following code:

if(get_query_var('bn')) {

    /**
     * CHANGE THE 'WPLANG' IN wp-config.php TO bn_BD ON THEME SWITCHING
     * Thanks: toscho
     * Source: http://wordpress.stackexchange.com/a/121136/22728
     * -------------------------------------------------- */
    
    add_filter( 'locale', 'toscho_change_language' );
    
    function toscho_change_language( $locale ) {
        return 'bn_BD';
    }

}

With checking isset() of the parameter in URL, loading of this code block. And using the theme's language file bn_BD.

But I'm actually curious about the logical proceedings:

  • Is this concept Ok?
  • Will it load the theme's language file successfully?
Source Link
Mayeenul Islam
  • 12.9k
  • 21
  • 85
  • 169

Changing interface language without multisite

I want to change the Theme's interface language without making multisite by passing langauage parameter into the URL.

<a href="<?php echo home_url('/')?lang=bn ?>">Bengali</a>

My thought is to use the following code:

get_query_var('bn') {

    /**
     * CHANGE THE 'WPLANG' IN wp-config.php TO bn_BD ON THEME SWITCHING
     * Thanks: toscho
     * Source: http://wordpress.stackexchange.com/a/121136/22728
     * -------------------------------------------------- */
    
    add_filter( 'locale', 'toscho_change_language' );
    
    function toscho_change_language( $locale ) {
        return 'bn_BD';
    }

}

With checking isset() of the parameter in URL, loading of this code block. And using the theme's language file bn_BD.

But I'm actually curious about the logical proceedings:

  • Is this concept Ok?
  • Will it load the theme's language file successfully?