Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 14th December 2024 20:35 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.