Hot answers tagged

6

I would like to recommend WPML, I use it on all of my bi/multi-lingual projects. It has great support and it makes WordPress truly multilingual, instead of only your content. The latest addition is the media module, which takes care of the images you upload to Posts and Pages. No need anymore to upload them for each language separately, the plugin now ...


6

The instance of this class is made global by WPML, so this should work: if ( ! empty ( $GLOBALS['sitepress'] ) ) { add_action( 'wp_head', function() { remove_action( current_filter(), array ( $GLOBALS['sitepress'], 'meta_generator_tag' ) ); }, 0 ); }


5

You don’t have to make anything special for WPML, using the regular translation code should be enough. See I18n for WordPress Developers in the Codex. Code preparation style.css Add Text Domain and Domain Path to your theme’s style.css. Example: /* * Theme Name: My awesome theme * Text Domain: my_awesome_theme * Domain Path: /languages */ ...


5

I came up with a function that does the job for now : /** * Creates a translation of a post (to be used with WPML) * * @param int $post_id The ID of the post to be translated. * @param string $post_type The post type of the post to be transaled (ie. 'post', 'page', 'custom type', etc.). * @param string $lang The language of the translated post (ie ...


4

_e() will translate the text passed as a argument to the language your site is currently set up to use (if the translation exists). Anyway, don't do that. Use it for text visible on the website, not for IDs/classes etc. To create context based css rules, simply add the WPML language ID as a body class: add_filter('body_class', 'wpml_body_class'); function ...


4

Try qtranslate...I use it religiously. Has some issues like with dates and times, but I always find a solution.


4

WPML defines constants that you can use go get the current language: ICL_LANGUAGE_CODE - current language code (eg: en,fr,sp). ICL_LANGUAGE_NAME_EN - Name of the current language in English (eg: English, French. Spanish). ICL_LANGUAGE_NAME - Name of current language, in the current language (eg: English, Français, Español).


4

I have no experience with the plugin whatsoever, but from a quick scout of their site, it looks like: ICL_LANGUAGE_CODE will give you the current language. Worth a try, anyway!


4

Within the code, can you see any syntax like either of the following? __( 'Hello, dear user!', 'my-text-domain' ) _e( 'Your Ad here', 'my-text-domain' ) That is, strings starting with __ (double underscores) or _e. If so, where the above says my-text-domain, you should find the name of your text domain.


3

WPML offers this feature. You can set it in the Languages adminsection, at the option Browser Language Redirect.


3

Assuming $new_lang holds the desired two letter language code (e.g. 'fr'), you can do this: global $sitepress; $current_lang = $sitepress->get_current_language(); //save current language $sitepress->switch_lang($new_lang); //...run query here; if you use WP_Query or get_posts make sure you set suppress_filters=0 ... ...


3

A .mo file is the machine readable Version of a .po file, which in turn holds the translation of a .pot file. Hence, the latter is what you want to have in the first place. And if it is your theme you want to localize, you certainly do not need a random plugin's simplified Chinese .mo file... Using either, poedit, any other gettext application or the ...


3

Let's say the original language of your site is english, then when visiting a german post you would return the title of the corresponding english post like that : // Get the post ID of original post $original_ID = icl_object_id( $post->ID, 'post', false, 'en' ); // Get original post title $original_title = get_the_title( $original_ID ); Hope that ...


3

Try this one, it worked very fine with me. $lang=get_bloginfo("language");


3

First of all i wouldn't use phpmyadmin for a database that large. Use something like Sequel Pro its free and easy to use. Second if you dont want the tables that WPML Created and you have removed the plugin from your site you can remove the tables that it creates. Upload the sql to a new database on your local machine and remove all this tables for each ...


3

Actually there is already in their API something for this: icl_object_id(ID, custom_taxonomy_name, return_original_if_missing,language_code) Works like a charm. More read on this : Language Dependent IDs


3

For the language filter from WPML to take effect you have to allow filters in get_posts. Default this is off. You can add suppress_filters=0 to your get_posts args and it should work. See: http://codex.wordpress.org/Template_Tags/get_posts#Parameters <ul id="archive-list"> <?php $args = array( 'suppress_filters' => false, 'numberposts' ...


2

I've done it with this bit of code: global $wpdb; $posts = get_posts(array('post_type'=>'...', 'posts_per_page'=>-1)); foreach($posts as $post) { $wpdb->update('wp_icl_translations', array('language_code'=>'es'), array('element_id'=> $post->ID)); }


2

1. Don't use query_posts for secondary loops This is just a general best practices recommendation and not the cause of your problem. 2. When you register the post type make sure 'public' => true, 3. Put the following in a template somewhere and report back the output. It will return the object of each registered custom post type and will verify ...


2

I've found what was going on, so I'm going to answer it for future reference, as it's a common issue without clear solution. TL;DR: If the WPML language which's not redirecting has a country code (eg. en-US instead of en) then you probably have the same bug. Jump to section "How to fix it". The Problem The problem arises at the redirection ...


2

If you want to have variables in your text to be translated the usual way would be with string formatting like so: <?php printf(__("text %s text2."), $message); ?> with integers: <?php printf(__("text %d text2."), $count); ?> with more then one placeholders: <?php printf(__("text %1$s text2 %2$S."), $message, $message2); ?> but ...


2

You can accomplish different sidebar content per language with either the plugin Widget Logic, or with the Dynamic Widgets plugin Alternatively you can make different sidebar templates per language and use a conditional on the language: if(ICL_LANGUAGE_CODE=='en'){ get_sidebar('en'); } if(ICL_LANGUAGE_CODE=='fr'){ get_sidebar('fr'); }


2

Which versions of WPML and WordPress are you using? I'm sure that you noticed that the old versions of WPML from wp.org only run on old WordPress versions (up to 3.0.5).


2

I'm not really up to date on WPML and how it handles translations, but my general understanding is that in most cases it simply creates duplicate entries for each language and links them together with the "original". However, I recently hade a similar problem where I needed the ability to add a "pluralized" version of the term names (as opposed to the ...


2

The way WPML works is that you have a translation or a duplication across all languages of your content, that way each language has access to all content. You can duplicate or better yet batch duplicate any content that you need for all languages. WPML makes it easy to maintain that content across all languages. When you update your posts in the default ...


2

Polylang seems to be a direct alternative to WPML. From the plugin description: Polylang allows you to create a bilingual or multilingual WordPress site. You write posts, pages and create categories and post tags as usual, and then define the language for each of them. The translation of a post, whether it is in the default language or not, is ...


2

My vote for qTranslate it supports a lot of languages and is very configurable :)


2

I had this problem with querying on two custom post types, using WP_Query. I had no problem querying for one type or the other in the array, but not both at the same time. Did not work: $args = array( 'post_type' => array('custom_type_1','custom_type_2'), 'posts_per_page' => 4 ); Did work: $args = array( 'post_type' => ...


2

You cannot translate text you don’t know. The translator must know the text before it was submitted – impossible. The only solution is: add all language strings manually for each sub site.


2

WPML has a pretty good documentation on how to make a theme compatible. Most of the time, all themes should work out of the box with WPML if the theme designer did follow the wp standards for internationalization. If you don't get further with that link and have any concrete problem we can help you with, please add the details of what goes wrong and how ...



Only top voted, non community-wiki answers of a minimum length are eligible