LOCALES
Table of Contents
- dateFormatFromString() : string
 - Format dates and times for localization
 - dateFormatFromTimeStamp() : string
 - Format dates and times for localization
 - getSystemLocales() : array<string|int, mixed>
 - Return the list of all locales available on the current OS, defined in cached file /cache/languages/locales_system.json
 - refreshSystemLocalesCache() : mixed
 - Create a data file containing the list of available locales on the current system
 - checkSystemLocales() : array<string|int, mixed>
 - Return a dynamic list of all locales available on the current OS
 - getLocaleGettextAliases() : array<string|int, string>
 - Return all alias of a locale with and without UTF-8 charset for Gettext
 - codeISO639a1toName() : string
 - Return the name of a language defined by its locale code or its ISO 639-1 (alpha-2) code.
 - load_locales() : mixed
 - Load the gettext catalogs of the user's preferred language.
 - determine_locale() : string
 - Determine the user's preferred language.
 - determine_locale_priority_stack() : array<string|int, string>
 - Determine the user's preferred language.
 - getAllLocales() : array<string|int, string>
 - Return the list of all locales defined in /languages/locales.json
 - localetoBCP47() : string
 - Return the BCP 47 code that matches the code of a locale.
 - getTranslatableLocales() : mixed
 - Get a list of translatable locales sorted by locale name
 
Functions
dateFormatFromString()
Format dates and times for localization
    
                dateFormatFromString(string $datetime) : string
        Use it for displaying data to the user, not formatting data for the db
Parameters
- $datetime : string
 - 
                    
comes in from the database in the format 'YYYY-MM-DD HH:MM:SS' e.g. 2013-01-31 15:54:55
 
Return values
string —dateFormatFromTimeStamp()
Format dates and times for localization
    
                dateFormatFromTimeStamp(int $timestamp) : string
        Use it for displaying data to the user, not formatting data for the db
Parameters
- $timestamp : int
 
Return values
string —getSystemLocales()
Return the list of all locales available on the current OS, defined in cached file /cache/languages/locales_system.json
    
                getSystemLocales([bool $display_code_only = FALSE ]) : array<string|int, mixed>
        Each entry of the returned array is locale code (format: ll_CC@variant) as key and its name as value [format: language (Country, Variant)].
ll is a mandatory language code CC is an optional country code variant is an optional script, money or collation code
If the source file is not readeable only the reference language is listed.
Parameters
- $display_code_only : bool = FALSE
 - 
                    
Display the code of the locale instead of its localized name (optional, FALSE by default)
 
Return values
array<string|int, mixed> —refreshSystemLocalesCache()
Create a data file containing the list of available locales on the current system
    
                refreshSystemLocalesCache([bool $force = FALSE ]) : mixed
        The file is stored at /cache/languages/locales_system.json
Parameters
- $force : bool = FALSE
 - 
                    
Forces the file overwriting if it already exists (optional, FALSE by default)
 
Return values
mixed —checkSystemLocales()
Return a dynamic list of all locales available on the current OS
    
                checkSystemLocales() : array<string|int, mixed>
        This function can be a bit of a time (1-2 s) running because it tests all possible variants of all known locales.
Return values
array<string|int, mixed> —getLocaleGettextAliases()
Return all alias of a locale with and without UTF-8 charset for Gettext
    
                getLocaleGettextAliases(string $locale) : array<string|int, string>
        Although locales codes have a canonical form and the LANG environment variable of operating systems respect it, Gettext doesn't always follow the standard. This function provides all the possible variants known to us on Windows 7, Mac, Debian 10 and OpenBSD 6.6 for one locale code.
These forms are provided to test if a locale is available on the current system and are not intended for users.
Parameters
- $locale : string
 - 
                    
Normalized code of a locale
 
Return values
array<string|int, string> —codeISO639a1toName()
Return the name of a language defined by its locale code or its ISO 639-1 (alpha-2) code.
    
                codeISO639a1toName( $codeISO) : string
    
        Parameters
Tags
Return values
string —load_locales()
Load the gettext catalogs of the user's preferred language.
    
                load_locales() : mixed
    
    
    
        Return values
mixed —determine_locale()
Determine the user's preferred language.
    
                determine_locale([null|string $force_locale = NULL ]) : string
        This function builds a language priority stack and return the first entry as the user's preferred language.
If $force_locale is passed, this function will try to use this locale first.
Parameters
- $force_locale : null|string = NULL
 - 
                    
Code of a locale (format: ll[_CC][@variant])(optional, NULL by default)
 
Return values
string —determine_locale_priority_stack()
Determine the user's preferred language.
    
                determine_locale_priority_stack([null|string $force_locale = NULL ]) : array<string|int, string>
        This function builds a language priority stack. The first is the highest priority.
If $force_locale is passed, this function will try to use this locale first.
Parameters
- $force_locale : null|string = NULL
 - 
                    
Code of a locale (format: ll[_CC][@variant])(optional, NULL by default)
 
Return values
array<string|int, string> —getAllLocales()
Return the list of all locales defined in /languages/locales.json
    
                getAllLocales([bool $display_code_only = FALSE ]) : array<string|int, string>
        Each entry of the returned array is locale code (format: ll_CC@variant) as key and its name as value [format: language (Country, Variant)].
ll is a mandatory language code CC is an optional country code variant is an optional script, money or collation code
If the source file is not readeable only the reference language is listed.
Parameters
- $display_code_only : bool = FALSE
 - 
                    
Display the code of the locale instead of its localized name (optional, FALSE by default)
 
Return values
array<string|int, string> —localetoBCP47()
Return the BCP 47 code that matches the code of a locale.
    
                localetoBCP47( $locale) : string
        The BCP 47 code is used in the lang attribute of any HTML tag. The list of supported languages is simple enough to avoid having to encounter any particular case.
The resolution table was built by hand because there is no systematic correspondence with an ISO language code.
Parameters
Tags
Return values
string —getTranslatableLocales()
Get a list of translatable locales sorted by locale name
    
                getTranslatableLocales(mixed $in_locale) : mixed
        This is a list of locales that a translator can use to translate a text and not a list of locales currently available on the system.
Each key is a locale code and its value a displayname.
return string[]
Parameters
- $in_locale : mixed