i18n_get_indexable()

Description

For field names / values using the i18n syntax, return all language versions, as necessary for indexing.

Parameters

ColumnTypeDefaultDescription
$text string The text to process

Return

string

Location

include/language_functions.php lines 176 to 216

Definition

 
function i18n_get_indexable($text)
{
    
// Make sure keywords don't get squashed together, then trim
    
$text str_replace(array("<br />","<br>","\\r","\\n","&nbsp;"), " "$text);
    
$text trim($text);

    
$text preg_replace('/~(.*?):/'','$text);// remove i18n strings, which shouldn't be in the keywords

    # For multiple keywords, parse each keyword.
    
if (substr($text01) != "," && (strpos($text",") !== false) && (strpos($text"~") !== false)) {
        
$s explode(","$text);
        
$out "";
        for (
$n 0$n count($s); $n++) {
            if (
$n 0) {
                
$out .= ",";
            }
            
$out .= i18n_get_indexable(trim($s[$n]));
        }
        return 
$out;
    }

    
# Split
    
$s explode("~"$text);

    
# Not a translatable field?
    
if (count($s) < 2) {
        return 
$text;
    }

    
$out "";
    for (
$n 1$n count($s); $n++) {
        if (
substr($s[$n], 21) != ":") {
            return 
$text;
        }
        if (
$out != "") {
            
$out .= ",";
        }
        
$out .= substr($s[$n], 3);
    }
    return 
$out;
}

This article was last updated 5th April 2025 21:35 Europe/London time based on the source file dated 28th January 2025 09:35 Europe/London time.