Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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

string

Location

include/language_functions.php lines 13 to 31

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 19th March 2024 04:05 Europe/London time based on the source file dated 8th March 2024 15:10 Europe/London time.