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


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

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

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


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


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


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

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


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

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

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

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

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

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

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

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


1

Because you are hardcoding the link, you will need to use icl_link_to_element() function and wrap any text you want to translate inside a gettext function: <?php icl_link_to_element( 'ID_of_your_news_page', 'page', '<h4>' . __('News') . '</h4>' ); ?> This way you will get the correct version of the link based on the current language with ...


1

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


1

There's a global variable called $wp_filter (you can see examples of it all through the source of /wp-includes/plugin.php. This probably isn't the WordPress Way to do it, but you could try something like this: global $wp_filter; var_dump( $wp_filter ); ...but note the caveat on http://codex.wordpress.org/Global_Variables -- "Accessing other globals ...


1

Technically, this is possible. Just make sure to use your strings after the parent plugin has loaded its language file. In terms of maintainability, this is not optimal. Your create a very strond dependency here: each time the parent plugin changes a string (adding a dot, removing a white space), you have to change your strings too. I would do this only to ...


1

In most cases, @vancoder's answer is absolutely correct. My situation appears to be fairly unique, but I want to share my experience so it may help someone else. In the case of this Nevada theme, the standard functions are not used in the template files. Apparently, Nevada uses the Lambda framework (something totally foreign to me) and so any text output ...


1

Wow. not sure of exactly what the culprit is (will dig further) but it seems that something about WPML was preventing the actual SQL query from requesting the custom post type in conjuction with standard posts and pages. When I disabled WPML it worked. Thanks for all the help everyone - I'm going to follow up on this issue once I have a more concrete idea of ...


1

To translate custom page templates you must select "Synchronize page template" in WPML options. For it to actually work the page template markup must be localized or internationalized using a recognized format, for example http://codex.wordpress.org/I18n_for_WordPress_Developers, and then have an accompanying .mo/.po file . WPML also has an addon called ...


1

Apologies, I find this a little bit a non-issue as it states clearly everywhere that WPML works 100% when you use a permalinks structure of day and name (http://domain.com/2012/02/07/sample-post/). If this is something you cannot accept, then you's better come to terms with the fact that WPML most likely is not going to work 100% for you. Or, to answer ...


1

Interesting questions, I'll try my best, but I hope others can also give input. re 1. Usually I use the theme's text domain also for strings that are likely to be present in the main WordPress translation file re 2. correct re 3. I think it is a good idea, but I don't know if it is bad practice or anything like that re 4. correct re 5. I also think it ...



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