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

string

Location

include/language_functions.php lines 14 to 38

Definition

 
function lang_or_i18n_get_translated($text$mixedprefix$suffix "")
{
    
$text trim((string) $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 7th July 2025 21:35 Europe/London time based on the source file dated 28th January 2025 09:35 Europe/London time.