icl_translate

The Polylang icl translate function.

Description

icl_translate( $context, (string) $name, (constant) $string = false, (constant) $bool = false, (constant) &$has_translation = null, (null) $lang = null ); 

Parameters (6)

0. $context
The context.
1. $name (string)
The name.
2. $string — Optional. (constant) => false
The string.
3. $bool — Optional. (constant) => false
The bool.
4. $has_translation — Optional. (constant) => &$has_translation = null
The has translation.
5. $lang — Optional. (null) => null
The lang.

Usage

  1. if ( !function_exists( 'icl_translate' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'polylang/modules/wpml/wpml-legacy-api.php'; 
  3.  
  4. // The context. 
  5. $context = null; 
  6.  
  7. // The name. 
  8. $name = ''; 
  9.  
  10. // The string. 
  11. $string = false; 
  12.  
  13. // The bool. 
  14. $bool = false; 
  15.  
  16. // The has translation. 
  17. $has_translation = &$has_translation = null; 
  18.  
  19. // The lang. 
  20. $lang = null; 
  21.  
  22. // NOTICE! Understand what this does before running. 
  23. $result = icl_translate($context, $name, $string, $bool, $has_translation, $lang); 
  24.  

Defined (1)

The function is defined in the following location(s).

/modules/wpml/wpml-legacy-api.php  
  1. function icl_translate( $context, $name, $string = false, $bool = false, &$has_translation = null, $lang = null ) { 
  2. // FIXME WPML can automatically registers the string based on an option 
  3. if ( empty( $string ) ) { 
  4. $string = PLL_WPML_Compat::instance()->get_string_by_context_and_name( $context, $name ); 
  5. return empty( $lang ) ? pll__( $string ) : pll_translate_string( $string, $lang );