_get_path_to_translation

Gets the path to a translation file for loading a textdomain just in time.

Description

(string|false) _get_path_to_translation( (string) $domain, (bool) $reset = false ); 

Caches the retrieved results internally.

Returns (string|false)

The path to the translation file or false if no translation file was found.

Parameters (2)

0. $domain (string)
Text domain. Unique identifier for retrieving translated strings.
1. $reset — Optional. (bool) => false
Whether to reset the internal cache. Used by the switch to locale functionality.

Usage

  1. if ( !function_exists( '_get_path_to_translation' ) ) { 
  2. require_once ABSPATH . WPINC . '/l10n.php'; 
  3.  
  4. // Text domain. Unique identifier for retrieving translated strings. 
  5. $domain = ''; 
  6.  
  7. // Whether to reset the internal cache. Used by the switch to locale functionality. 
  8. $reset = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _get_path_to_translation($domain, $reset); 
  12.  

Defined (1)

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

/wp-includes/l10n.php  
  1. function _get_path_to_translation( $domain, $reset = false ) { 
  2. static $available_translations = array(); 
  3.  
  4. if ( true === $reset ) { 
  5. $available_translations = array(); 
  6.  
  7. if ( ! isset( $available_translations[ $domain ] ) ) { 
  8. $available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain ); 
  9.  
  10. return $available_translations[ $domain ];