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.