WPML – how to get the permalinks to display also the default language
EDIT: This feature has been added to the latest version of the plugin. https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/
EDIT: This feature has been added to the latest version of the plugin. https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/
WPML has a feature called “Automatically Adjust IDs” which detect when specific items are loaded and adjust IDs so that the results are adjusted for the active language. This functionality is enabled by default and can be accessed via WPML->Languages (visible in Advanced mode):
For example: I’m a Hungarian user, but my IP shows I’m in Germany while I use an English browser. The most convenient would be English for me, because that is my choice. There’s a PHP superglobal variable, called $_SERVER. It stores information about the server running the page and about the client who requested the … Read more
Assuming you’re talking about the front-end and you have your strings properly internationalized, you just need to insert the load_theme_textdomain() function to tell wordpress where are your .po files. this is how the Toolbox Theme does it: /** * Make theme available for translation * Translations can be filed in the /languages/ directory * If … Read more
I found a solution, realy dirty, but works. In the core.php file of the polylang plugin I found this stuff: // NOTE: I believe there are two ways for a plugin to force the WP language // as done by xili_language and here: load text domains and reinitialize wp_locale with the action ‘wp’ // as … Read more
I have used qTransalte a lot of times… i some cases i have used this kinda of code for widgets and special elements in the design such as the logo / images $bloginfo = get_bloginfo( ‘language’ ); if ($bloginfo == ‘he-IL’) { // hebrew sidebar here } else { // English sidebar here } . … Read more
So I’ve managed to solve this. The googl_shortlink function from above now looks like this: function googl_shortlink($url, $post_id = false) { global $post; if (!$post_id && $post) $post_id = $post->ID; elseif ($post_id) $post = get_post($post_id); // list all the active languages in an array $enabled_languages = get_option(‘qtranslate_enabled_languages’); if (is_404()) return; if ($post && $post->post_status != … Read more
From qTranslate’s official support forums The function to get the current language is qtrans_getLanguage()
Basically read the source for the function load_plugin_textdomain(): function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) Ignore the second parameter, it was deprecated a long time ago. An example from my plugin T5 Taxonomy Location: protected function load_language() { load_plugin_textdomain( ‘plugin_t5_tax_location’, FALSE, plugin_basename( dirname( __FILE__ ) ) . ‘/languages’ ); } The first … Read more
You might be interested in url_to_postid function Used as follows from your wpsx_redefine_locale function: $url = $_SERVER[‘REQUEST_URI’]; $postid = url_to_postid( $url ); Note that this does not return the post id for custom post types but the function is located in /wp-includes/rewrite.php and might be extended if needed. UPDATE: here’s your sample: function my_function(){ if … Read more