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

i18n_get_collection_name()

Description

Translates collection names

Parameters

ColumnTypeDefaultDescription
$mixedcollection mixed
$index string "name"

Return

string

Location

include/language_functions.php lines 104 to 161

Definition

 
function i18n_get_collection_name($mixedcollection$index="name")
{
    global 
$lang;

    
# The function handles both strings and arrays.
    
if (!is_array($mixedcollection)) {
        
$name_untranslated $mixedcollection ?? "";
    } else {
        
$name_untranslated $mixedcollection[$index] ?? "";

        
# Check if it is a Smart Collection
        
if (isset($mixedcollection['savedsearch']) && ($mixedcollection['savedsearch'] != null)) {
            return 
escape($lang['smartcollection'] . ": " $name_untranslated);
        }
    }

    
# Check if it is a Default Collection (n)
    
$name_translated preg_replace('/(^Default Collection)(|(\s\d+))$/'$lang["mycollection"] . '$2'$name_untranslated, -1$translated);
    if (
$translated == 1) {
        return 
escape($name_translated);
    }

    
# Check if it is a Upload YYMMDDHHMMSS
    
$upload_date preg_replace('/(^Upload)\s(\d{12})$/''$2'$name_untranslated, -1$translated);
    if (
$translated != 1) {
        
$upload_date preg_replace('/(^Upload)\s(\d{14})$/''$2'$name_untranslated, -1$translated);
    }

    if (
$translated == 1) {
        
# Translate date into MySQL ISO format to be able to use nicedate()
        
if (strlen($upload_date) == 14) {
            
$year substr($upload_date04);
            
$upload_date=substr($upload_date2);
        } else {
            
$year substr($upload_date02);
            if ((int)
$year > (int)date('y')) {
                
$year = ((int)substr(date('Y'), 02)-1) . $year;
            } else {
                
$year substr(date('Y'), 02) . $year;
            }
        }
        
$month substr($upload_date22);
        
$day substr($upload_date42);
        
$hour substr($upload_date62);
        
$minute substr($upload_date82);
        
$second substr($upload_date102);
        
$date nicedate("$year-$month-$day $hour:$minute:$second"true);
        return 
escape($lang['upload'] . ' ' $date);
    }

    
# Check if it is a Research Request
    
if (substr($name_untranslated09) == "Research:") {
        return 
escape("{$lang["research"]}: " i18n_get_translated(substr($name_untranslated,9)));
    }

    
# Ordinary collection - translate with i18n_get_translated
    
return escape(i18n_get_translated($name_untranslated));
}

This article was last updated 15th December 2024 16:35 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.