Collections functions
General functions
Render functions
Theme permission 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 83 to 144

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 Request
    
if(substr($name_untranslated09) == "Research:")
        {
        return 
htmlspecialchars("{$lang["research"]}: " i18n_get_translated(substr($name_untranslated,9)));
        }

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

This article was last updated 2nd October 2022 17:35 Europe/London time based on the source file dated 5th July 2022 14:55 Europe/London time.