Collections functions
Encryption functions
General functions
Theme permission functions
Video functions
Resource functions

lang_or_i18n_get_translated()

Description

Translates field names / values using two methods: First it checks if $text exists in the current $lang (after $text is sanitized and $mixedprefix - one by one if an array - and $suffix are added). If not found in the $lang, it tries to translate $text using the i18n_get_translated function.

Parameters

ColumnTypeDefaultDescription
$text string
$mixedprefix string
$suffix string ""

Return

void

Location

include/language_functions.php lines 13 to 31

Definition

 
function lang_or_i18n_get_translated($text$mixedprefix$suffix "")
    {
    
$text=trim($text);
    global 
$lang;

    if (
is_array($mixedprefix)) {$prefix $mixedprefix;}
    else {
$prefix = array($mixedprefix);}
    for (
$n 0;$n<count($prefix);$n++) {
        
$langindex $prefix[$n] . strip_tags(strtolower(str_replace(array(", "" ""\t""/""("")"), array("-""_""_""and"""""), $text))) . $suffix;

        
# Checks if there is a $lang (should be defined for all standard field names / values).
        
if (isset($lang[$langindex])) {
            
$return $lang[$langindex];
            break;
        }
    }    
        if (isset(
$return)) {return $return;}
        else {return 
i18n_get_translated($text);} # Performs an i18n translation (of probably a custom field name / value).
    
}

This article was last updated 21st September 2020 21:05 Europe/London time based on the source file dated 7th July 2020 14:31 Europe/London time.