Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

i18n_get_collection_name()

Description

Translates collection names

Parameters

ColumnTypeDefaultDescription
$mixedcollection mixed
$index string "name"

Return

string

Location

include/language_functions.php lines 97 to 154

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 22nd May 2024 16:05 Europe/London time based on the source file dated 3rd May 2024 14:45 Europe/London time.