WPML Coding API
WPML offers functions that can be used in your WordPress theme to provide correct support for multilingual themes.
| Function | Purpose | Notes |
|---|---|---|
| do_action(‘icl_language_selector’) | Insert the drop down language selector. | Described in the language setup section of the getting started guide. |
| do_action(‘icl_navigation_menu’) | Insert the top navigation menu. | Described in the navitaion section of the getting started guide. |
| do_action(‘icl_navigation_breadcrumb’) | Insert the breadcrumbs trail. | |
| do_action(‘icl_navigation_sidebar’) | Insert the sidebar navigation. | |
| icl_get_home_url() | Link to the home page in the active language. | Described in the home page link section of the getting started guide. |
| icl_get_languages(‘skip_missing=N’) | Used for building custom language selectors. | Described in the custom language switcher section of the getting started guide. |
| icl_link_to_element(ID, type, text, arguments, anchor) | Used for creating language dependent links in themes. | Described in the hard coded links section of the getting started guide. |
| icl_object_id(ID, type, return_original_if_missing, language_code) | Used for calculating the IDs of objects (usually categories) in the current language. | Described in the language dependent IDs section of the getting started guide. |
Language constants
WPML defines the following constants which can be used in the theme:
| Constant | Description | Example |
|---|---|---|
| ICL_LANGUAGE_CODE | Code for the current language | fr |
| ICL_LANGUAGE_NAME | Name of current language, in the current language | Français |
| ICL_LANGUAGE_NAME_EN | Name of the current language name in English | French |
Disabling WPML’s CSS and JS files
WPML comes with its own CSS and JS files that style its navigation and drop-down language switcher.
If you don’t need them in your theme, you can tell WPML not to load these files. Do to that, define the following constants in your theme:
| Constant | The file it disables |
|---|---|
| ICL_DONT_LOAD_NAVIGATION_CSS | Navigation stylesheets – cms-navigation-base.css and cms-navigation.css |
| ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS | Drop-down language selector stylesheet – language-selector.css |
| ICL_DONT_LOAD_LANGUAGES_JS | Drop-down language selector Javascript – sitepress.js |
To set these constants, define them in the theme’s functions.php file. For example:
define('ICL_DONT_LOAD_NAVIGATION_CSS', true);
English
Hi….
Its really a nice plugin given by WPML.org,
I go thoroly….And implement it,
But now one and only problem is I cant found .po and .mo files for each languages I Used.
So please give me Hint, from where can I get those files.
Hi
Thanks for excellent plugin but I’ve got problems using it.
I’ve try to check current language but
gives me only ‘en’ value instead of ‘ru’ when I’m on
http://www.domain.com/ru/whatever.htmlWhat have I do wrong? How to check current language better?
Regards Serguey
This sort of thing is exactly what the forum is used for. Please post it there with details that will allow us to see the problem in your site AND recreate it locally.
Hi … and thanks (from the bottom of my developer heart) for this great plugin!
WMPL is now an integrated part of our WordPress framework. It is the best tool we found to produce stable WP themes for our canadian bilingual clients/users.
About those functions, is there any way to re-use them within TinyMCE WYSIWYG generated contents (
the_content) like somekind of a “shortcode” brackets to generate sticky links ?… Or maybe this technical question is a case for the forum.
Thank’s anyway & Keep on the good work.
Which functions specifically would you use as shortcodes?
does it support ‘hidden’ class for styling currently active language? like .current_page_item in wp itselft to style selected page in navigation.
here is the example what i’m trying to achieve:
http://www.dixevil.com/limoluxx/
Hi there,
Thank you for such a wonderful plugin. I want to be able to auto create empty translation pages for each new post created in my website. which tables, other than the wp_icl_translations are affected?
Only wp_icl_translations. You need to add new rows with other languages and the same trid as the original.
Thank you for the instant response. I will start working on it tonight.
How to find a list of available languages of current site and what language is the main one.
p.s. Thanks for plugin.
Hi, to make our decision, our developer is asking: “Please ask your plugin author (of the plugin that creates multiple domains) how it differentiates between domains. How the plugin determines these domains is important in this scenario.”
Could you please, let us know the variable to get the different domains?
How to get constant (ICL_LANGUAGE_CODE) in my plugin?
echo ICL_LANGUAGE_CODE; not work and print only text “ICL_LANGUAGE_CODE”.
Please help.
To ease theme development for novice programmers, something like “icl_get_name_of_post( … )”, icl_get_permalink_of_post( … ) etc could be helpful.
amir , how to create a custom wordpress post creator in frontend.
i can add a new post using , wp_insert_post().
But wat value i need to pass for post_content and post_title or something else to create a post in a different language, say arabic..