How make a multi language routes, with rewrite rules or rewrite endpoints?
How make a multi language routes, with rewrite rules or rewrite endpoints?
How make a multi language routes, with rewrite rules or rewrite endpoints?
My problem here is that get_query_var(‘language’) isn’t defined in the function set_my_locale Because get_locale (which applies the filter locale) is called before wp() (which parses the query & sets up the variables). You’ll have to manually inspect the request yourself: if ( strpos( $_SERVER[‘REQUEST_URI’], ‘/de/’ ) === 0 ) { // German } else { … Read more
Actually you need to hook in the ‘locale’ filter to set the language you want: add_filter(‘locale’, function($locale) { return esc_attr($_GET[‘language’]); }); Then in the links of your switch, you need to pass the language variable: <a href=”https://wordpress.stackexchange.com/questions/260015/<?php echo add_query_arg(“language’, ‘xx_XX’) ?>”>XX</a> Where xx_XX is the language locale code for language XX
http://codex.wordpress.org/Function_Reference/load_theme_textdomain
You can create a custom field, give it a value of lang=’ur’ and check for it in your header.php. Add the custom field from the Custom Fields box. Let’s call it page_lang. Give it a value of lang=’ur’. In header.php: <?php global $post; $lang = get_post_meta(get_the_ID(), ‘page_lang’, true); ?> <body <?php body_class();?> <?php echo $lang;?>> … Read more
This can be done via cookies. We set it with Javascript, reload the page and display different menus in PHP using its value. First, print the script at the site footer (see comments). Note: would be better to enqueue this together with your theme scripts. add_action( ‘wp_footer’, ‘wpse_77220_language_cookie’ ); /** * Cookie script based on … Read more
I don’t know how qTraslate works, but you can pass filters to Widget Logic , you basically duplicate each widget, one for each language. I have used this technique with WPML to show widgets in separate languages that can sometimes be difficult ( such as when they make direct DB queries).
Create a subdomain for each language, set the main site to English. Then use the plugin Multilingual Press to chain these subdomains together. It has an option to redirect the visitor to the correct single page too if it is translated on another subdomain (not sure if that is part of the free version). Subdomains … Read more
Less complicated is to use the plugin’s Quicktags and use the Gettext functions to print the content in the site. [:en]English[:pt]Português Quicktags docs Another option is to do just like qTranslate interface does with the post titles: Create one custom field for each language in your meta box: qTrans documentation is not consolidated, so analyzing … Read more
When naming your po and mo files in a theme, you need to only make use of the language code to name these files. Any other convention will not work For example, my blog is in Afrikaans and the localization language code is af_AF. My mo and po files are named accordingly, ie, af_AF.po and … Read more