Tag Info

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 ...


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 */ ...


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.


4

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 ...


3

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!


3

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


3

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).


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' ...


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

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


3

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 ); }


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 ...


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

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 ... ...


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

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 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

Thanks for that mike23, was a lifesaver for me today. However that exact code didn't work for me, I did have to do some modifications in order to get it to work in my situation which may be due to a newer version of the WPML plugin. I had to change: $original_ID = icl_object_id( $post->ID, 'post', false, 'en' ); to: $original_ID = icl_object_id( ...


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

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

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 ...


2

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


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

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 ...


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 ...


1

Although @brasofilo already has given the correct answer, I would like to point out that WPML offers another way to displaying a link (to content within your website). Say that you would like a link in the footer going to the About (with an ID of 3) page, you could code that as follows: Using icl_link_to_element(ID, type, text, arguments, anchor): ...


1

When you develop a site on wordpress you may want to create posts/pages with the same name, something that wordpress does not allow by default. This is statement is not true. WordPress will allow you to set up pages with the "directory" structure that you specified right out of the box. I was just able to do this on my test installation. I created a ...



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