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

resolve_pdf_language()

Description

Function to convert the user's language into an HTML2PDF supported language.

Scans the HTML2PDF locale folder to create a list of supported languages to compare against
the set user language. Also resolves dialects when possible. Fallback set to 'en'.

Parameters

This function accepts no parameters.

Return

string

Location

include/pdf_functions.php lines 326 to 356

Definition

 
function resolve_pdf_language()
{
    global 
$language;

    
$asdefaultlanguage 'en';

    
$supported_lang_files scandir(__DIR__ '/../lib/html2pdf/src/locale');
    
$supported_langs      = array();

    foreach (
$supported_lang_files as $file) {
        
$sl pathinfo($filePATHINFO_FILENAME);
        if (!
in_array($sl, array("",".",".."))) {
            
$supported_langs[] = $sl;
        }
    }
    if (
in_array($language$supported_langs)) {
        return 
$language;
    } else {
        switch (
$language) {
            case 
"es-AR":
                return 
"es";
                break;
            case 
"pt-BR":
                return 
"pt";
                break;
            default:
                
// this includes en-US
                
return $asdefaultlanguage;
        }
    }
}

This article was last updated 11th February 2025 18:35 Europe/London time based on the source file dated 21st January 2025 15:20 Europe/London time.