I want to make a site in 2 languages, but all the content will be absolutely the same (all posts will not be translated).
The only difference will be in things like theme messages (like 'Search', 'The page not found') that will be translated according to WPLANG. Also I have to have an ability to make some conditions in theme, according to WPLANG.
The multite solution is not good for me, as I don't want to copy all the post and taxonomies on two sites.
I thought to add a identification via URL (like www.mysite.com/?lang=en), to define WPLANG according to this, and store this variable in session, and, by this way, use it in theme.
But may be there is a better solution?

1 Answer 1


Storing it in a session would certainly be possible, but is not necessary at all.
Unless you're looking for a way to not include the query string in subsequently visited URLs. Here I'd rather go with a cookie than a session, since WP already relies on cookies and does not use sessions. But that's a matter of personal taste, I suppose.

In your wp-config.php, you can define WPLANG conditionally like so (wp-config.php is loaded early, but other than that a normal php file like any other):

if ( isset( $_GET['lang'] ) ) {
    define( 'WPLANG', $_GET['lang'] );
} else {
    define( 'WPLANG', 'en_US' );

Or, if you'd like to use two-character identifiers for the query parameter and/or make it default to a certain language (here: English) if the parameter is invalid:

$language = isset( $_GET['lang'] ) ? $_GET['lang'] : 'en';
switch ( $language ) {
    case 'de':
        define( 'WPLANG', 'de_DE' );

    case 'en':
        define( 'WPLANG', 'en_US' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.