Skip Navigation
Updated
May 14, 2024

WPML provides a set of constants you can use in your theme or plugin’s PHP files and templates.

Besides constants defined by the WPML core plugin, you can use constants available for our add-on plugins.

On This Page:

WPML Multilingual CMS Constants

ICL_DISABLE_CACHE

Use this constant to disable WPML object caching. The default value is false.

ICL_DONT_LOAD_LANGUAGES_JS

Setting this constant to true removes the language switcher JavaScript file (e.g.
\sitepress-multilingual-cms\templates\language-switchers\legacy-dropdown\script.js).

ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS

Setting this constant to true removes the language switcher CSS (e.g.
\sitepress-multilingual-cms\templates\language-switchers\legacy-dropdown\style.css)

WPML_TRANSLATION_AUTO_UPDATE_ENABLED

For page builders, WPML provides a feature for automatically updating content.

To disable this feature set the value of this constant to false.

WPML_TAXONOMY_TRANSLATION_MAX_TERMS_RESULTS_SET

Use this constant to set the number of terms to display on the WPMLTaxonomy translation page. 

The default value is 1000.

WPML_SAVE_XLIFF_PATH

Use this constant to define the server path for saving XLIFF files when downloading jobs from the WPMLTranslations page. For example: 

define('WPML_SAVE_XLIFF_PATH', '/home/test-user/Desktop');

After downloading a translation job, a copy of the file will be created in the defined folder.

WPML_DO_NOT_RESIZE_UPLOADED_FLAGS

By default, WPML’s language switcher flags are automatically resized to 18×12 pixels for consistency. 

Sometimes, you might not want to resize your flags. Fox example, they might be handled by a custom CSS or JavaScript or you want to display a custom animated GIF. In such cases, you can turn off automatic resizing by setting this constant’s value to true.

For more information check our page about customizing the language switcher flags.

WPML_INSTALLER_LOGGING

Setting this constant to true enables logging of everything related to the WPML installer. This will create a log file called installer.log in your site’s ..\wp-content\plugins\sitepress-multilingual-cms\vendor\otgs\installer\ folder. 

This constant is intended to be used by developers only. For generic installer logs please go to WPMLSupport and then the Installer Support page in your site’s admin.

OTGS_DISABLE_AUTO_UPDATES

If you set this constant’s value to true, WPML and Toolset will stop automatically checking for updates. You will need to check for updates manually.

WPML_EXPORT_ALL_TO_XLIFF_LIMIT

You can use this constant to set the maximum amount of jobs that can be exported to XLIFF from the WPMLTranslations page.

The default value is 1700. This is the number of jobs that all servers should be able to process in a reasonable time. If your site runs on a fast server, you can increase this limit if needed.

WPML String Translation Constants

WPML_ST_SYNC_TRANSLATION_FILES

Setting this constant to true syncs WPML translation files (MO files) between multiple servers.

For more information check our page about syncing translation files for sites running on multiple servers.

WPML_ST_MO_SCANNING_LIMIT

WPML String Translation scans and imports MO files to make them available for translation. You can use this constant to define the number of MO files that can be imported in one request.

The default value is 20000.

WPML CMS Nav Constants

WPML_CMS_NAV_DISABLE_CACHE

Setting this constant to true disables WPML CMS Navigation caching. 

For more information check our page about the WPML CMS Navigation plugin.

ICL_DONT_LOAD_NAVIGATION_CSS

Setting this constant to true disables the loading of cms-navigation-base.css and cms-navigation.css files.

WooCommerce Multilingual Constants

WCML_GEOLOCATED_COUNTRY

Use this constant to force WooCommerce Multilingual to use a specific country when querying a geolocated country.

The constant value should include a two-digit country code (e.g. GH for Ghana).

define( 'WCML_GEOLOCATED_COUNTRY', 'GH' );

This constant can be useful for testing. For custom modules, please use the dedicated API hook.

Advanced Custom Fields Multilingual Constants

ACFML_EXCLUDE_FIELD_GROUP_STRINGS_IN_POST_JOBS

As of ACFML 2.0.4, you can use this constant to disable the feature to include field group strings in the post translation job.

To disable this feature, just add the following in wp-config.php:

define( 'ACFML_EXCLUDE_FIELD_GROUP_STRINGS_IN_POST_JOBS', true );

Note 1: If a translation job was already created with the field group strings, the user needs to cancel it and create a new job.

Note 2: This does not affect the main field group translation feature. Field labels and Choices can be translated via String Translation directly.

ACFML_HIDE_FIELD_ANNOTATIONS

To each translated field, ACF Multilingual adds information about the value in the original language. You can use this constant to hide annotation from translated fields.

To remove this information you can add the following line to your site’s wp-config.php file:

define( 'ACFML_HIDE_FIELD_ANNOTATIONS', true );

ACFML_REPEATER_SYNC_DEFAULT

You can use this constant to set the default value of the repeater field sync feature. It is set to true by default.

ACFML_SCAN_LOCAL_FIELDS

Setting this constant to false disables scanning of JSON files for local fields.

This means that if you change the translation preference in local fields, it won’t sync to the database. You need to set the translation preference manually for fields. 

For more information check out the official ACF documentation about using local JSON.