1

I have some work for wordPress internationalization. Actually, I got good results.

Part of my code:

add_filter( 'query_vars', 'queryi18n' );

function queryi18n( $query_vars ){
    $query_vars[] = 'lang';
    return $query_vars;
}

/**********************/

add_action( 'init', 'rule' );

function rule() {
    add_rewrite_rule(
        '^(en|fr|de|ru)/([^/]+)/?$',
        'index.php?lang=$matches[1]&name=$matches[2]',
        'top'
    );
}

Result: localhost/en/hello-world it returns me a query.

$wp_query->query_vars['lang'] //en

Everything is fine up to this point. So I can run the persistent connection structure of WordPress properly with multi language support.

But there is a small detail:

If the LANGUAGE variable is checked in some way, I need to add that language code to all INTERNAL links of WordPress except for external links.

So to summarize briefly:

If the browser -> "localhost/ru/hello-world" connection is opened, I want all links within the site to be changed to "localhost/ru/...".

All help suggestions are considered. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.