Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource 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 372 to 407

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 24th November 2020 06:05 Europe/London time based on the source file dated 9th September 2020 09:35 Europe/London time.