Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

i18n_get_collection_name()

Description

Translates collection names

Parameters

ColumnTypeDefaultDescription
$mixedcollection mixed
$index string "name"

Return

void

Location

include/language_functions.php lines 83 to 145

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 
htmlspecialchars($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 htmlspecialchars($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 
htmlspecialchars($lang['upload'] . ' ' $date);
        }

    
# Check if it is a Research: [..]
    
if (substr($name_untranslated,0,9)=="Research:"){
    return 
$lang["research"].": ".i18n_get_translated(substr($name_untranslated,9));
    }
    
//$name_translated = preg_replace_callback('/(^Research:)(\s.*)/', function ($matches){return i18n_get_translated($matches[2]);}, $name_untranslated, -1, $translated);
    //if ($translated==1) {return htmlspecialchars($lang["research"] . ": " . $name_translated);}

    # Ordinary collection - translate with i18n_get_translated
    
return htmlspecialchars(i18n_get_translated($name_untranslatedfalse));
    }

This article was last updated 1st December 2020 09:05 Europe/London time based on the source file dated 7th July 2020 14:31 Europe/London time.