functions-i18n.php
Table of Contents
Constants
- SITE_LOCALE = 'en_US'
Functions
- getLanguageArray() : mixed
- functions-i18n.php -- support functions for internationalization
- generateLanguageList() : array<string|int, mixed>
- Returns an array of available language locales.
- setMainDomain() : mixed
- Sets the locale, etc. to the zenphoto domain details.
- gettext_th() : string
- Gettext replacement function for separate translations of third party themes.
- ngettext_th() : string
- ngettext replacement function for separate translations of third party themes.
- gettext_pl() : string
- Gettext replacement function for separate translations of third party plugins within the root plugins folder.
- ngettext_pl() : string
- ngettext replacement function for separate translations of third party plugins within the root plugins folder.
- i18nSetLocale() : string
- Wrapper function for setLocale() so that all the proper permutations are used Returns the result from the setLocale call
- setupDomain() : mixed
- Sets the translation domain and type for optional theme or plugin based translations
- setupCurrentLocale() : mixed
- Setup code for gettext translation Returns the result of the setlocale call
- getLangAttributeLocale() : string
- Converts underscore locales like "en_US" to valid IANA/BCP 47 hyphen locales like "en-US" Needed for example in JS or HTML "lang" attributes.
- parseHttpAcceptLanguage() : array<string|int, mixed>
- This function will parse a given HTTP Accepted language instruction (or retrieve it from $_SERVER if not provided) and will return a sorted array. For example, it will parse fr;en-us;q=0.8
- validateLocale() : mixed
- checks a "supplied" locale against the valid locales.
- getUserLocale() : mixed
- Returns a saved (or posted) locale. Posted locales are stored as a cookie.
- get_language_string() : string
- Returns the sring for the current language from a serialized set of language strings Defaults to the string for the current locale, the en_US string, or the first string which ever is present
- getTimezones() : unknown
- Returns a list of timezones
- timezoneDiff() : int
- Returns the difference between the server timez one and the local (users) time zone
- getAllTranslations() : mixed
- returns a serialized "multilingual array" of translations Used for setting default options with multi-lingual strings.
- getLanguageSubdomains() : mixed
- creates an SEO language prefix list
- getLanguageText() : string
- Returns a canonical language name string for the location
- getSystemLocales() : array<string|int, mixed>
- Gets all locales suppported on the current server as a multidimensional array
- getLanguageDisplayName() : string
- Returns the real language name to the locale passed.
- printLangAttribute() : mixed
- Prints the lang="" attribute for the main <html> element.
- getFormattedLocaleDate() : string
- Returns a locale aware - e.g. translated day and month names - formatted date. Requires the PHP intl extension to work properly Otherwise returns standard formatted date.
Constants
SITE_LOCALE
public
mixed
SITE_LOCALE
= 'en_US'
Functions
getLanguageArray()
functions-i18n.php -- support functions for internationalization
getLanguageArray() : mixed
generateLanguageList()
Returns an array of available language locales.
generateLanguageList([mixed $all = false ]) : array<string|int, mixed>
Parameters
- $all : mixed = false
Return values
array<string|int, mixed>setMainDomain()
Sets the locale, etc. to the zenphoto domain details.
setMainDomain() : mixed
Returns the result of setupCurrentLocale()
gettext_th()
Gettext replacement function for separate translations of third party themes.
gettext_th(string $string[, string $theme = Null ]) : string
Parameters
- $string : string
-
The string to be translated
- $theme : string = Null
-
The name of the plugin. Only required for strings on the 'theme_description.php' file like the general theme description. If the theme is the current theme the function sets it automatically.
Return values
stringngettext_th()
ngettext replacement function for separate translations of third party themes.
ngettext_th(string $msgid1, string $msgid2, int $n[, string $theme = NULL ]) : string
Parameters
- $msgid1 : string
- $msgid2 : string
- $n : int
- $theme : string = NULL
Return values
stringgettext_pl()
Gettext replacement function for separate translations of third party plugins within the root plugins folder.
gettext_pl(string $string, string $plugin) : string
Parameters
- $string : string
-
The string to be translated
- $plugin : string
-
The name of the plugin. Required.
Return values
stringngettext_pl()
ngettext replacement function for separate translations of third party plugins within the root plugins folder.
ngettext_pl(string $msgid1, string $msgid2, int $n, string $plugin) : string
Parameters
- $msgid1 : string
- $msgid2 : string
- $n : int
- $plugin : string
Return values
stringi18nSetLocale()
Wrapper function for setLocale() so that all the proper permutations are used Returns the result from the setLocale call
i18nSetLocale( $locale) : string
Parameters
Return values
stringsetupDomain()
Sets the translation domain and type for optional theme or plugin based translations
setupDomain([mixed $domain = NULL ][, $type = NULL ]) : mixed
Parameters
setupCurrentLocale()
Setup code for gettext translation Returns the result of the setlocale call
setupCurrentLocale([string $override = NULL ]) : mixed
Parameters
- $override : string = NULL
-
force locale to this
getLangAttributeLocale()
Converts underscore locales like "en_US" to valid IANA/BCP 47 hyphen locales like "en-US" Needed for example in JS or HTML "lang" attributes.
getLangAttributeLocale([string $locale = NULL ]) : string
Parameters
- $locale : string = NULL
-
a locale like "en_US", if empty the current locale is used
Tags
Return values
stringparseHttpAcceptLanguage()
This function will parse a given HTTP Accepted language instruction (or retrieve it from $_SERVER if not provided) and will return a sorted array. For example, it will parse fr;en-us;q=0.8
parseHttpAcceptLanguage([string $str = NULL ]) : array<string|int, mixed>
Thanks to Fredbird.org for this code.
Parameters
- $str : string = NULL
-
optional language string
Return values
array<string|int, mixed>validateLocale()
checks a "supplied" locale against the valid locales.
validateLocale(string $userlocale, mixed $source) : mixed
Returns a valid locale if one exists else returns NULL
Parameters
- $userlocale : string
- $source : mixed
getUserLocale()
Returns a saved (or posted) locale. Posted locales are stored as a cookie.
getUserLocale() : mixed
Sets the 'locale' option to the result (non-persistent)
get_language_string()
Returns the sring for the current language from a serialized set of language strings Defaults to the string for the current locale, the en_US string, or the first string which ever is present
get_language_string(string $dbstring[, string $locale = NULL ]) : string
Parameters
- $dbstring : string
-
either a serialized languag string array or a single string
- $locale : string = NULL
-
optional locale of the translation desired
Return values
stringgetTimezones()
Returns a list of timezones
getTimezones() : unknown
Return values
unknowntimezoneDiff()
Returns the difference between the server timez one and the local (users) time zone
timezoneDiff(string $server, string $local) : int
Parameters
- $server : string
- $local : string
Return values
intgetAllTranslations()
returns a serialized "multilingual array" of translations Used for setting default options with multi-lingual strings.
getAllTranslations(string $text) : mixed
Parameters
- $text : string
-
to be translated
getLanguageSubdomains()
creates an SEO language prefix list
getLanguageSubdomains() : mixed
getLanguageText()
Returns a canonical language name string for the location
getLanguageText([string $loc = NULL ][, mixed $separator = NULL ]) : string
Parameters
- $loc : string = NULL
-
the location. If NULL use the current cookie
- $separator : mixed = NULL
Return values
stringgetSystemLocales()
Gets all locales suppported on the current server as a multidimensional array
getSystemLocales([bool $plainarray = false ]) : array<string|int, mixed>
Parameters
- $plainarray : bool = false
-
Default false for a multidimensial array grouped by locale base. Set to true to generate a single dimensional array with all locales.
Tags
Return values
array<string|int, mixed>getLanguageDisplayName()
Returns the real language name to the locale passed.
getLanguageDisplayName(string $locale) : string
If available it will use the native PHP Locale class. It returns the name in the language/locale currently set. Otherwise the far more limited internal Zenphoto catalogue stored in getLanguageArray() will be used.
Parameters
- $locale : string
-
A vaild locale.
Tags
Return values
stringprintLangAttribute()
Prints the lang="" attribute for the main <html> element.
printLangAttribute([string $locale = null ]) : mixed
Parameters
- $locale : string = null
-
Default null so the current locale is used. Or a locale like "en_US" which will get the underscores replaced by hyphens to be valid
Tags
getFormattedLocaleDate()
Returns a locale aware - e.g. translated day and month names - formatted date. Requires the PHP intl extension to work properly Otherwise returns standard formatted date.
getFormattedLocaleDate([string $format = 'Y-m-dd' ][, string|int $datetime = '' ]) : string
Parameters
- $format : string = 'Y-m-dd'
-
An ICU dateformat string
- $datetime : string|int = ''
-
A date() compatible string or a timestamp. If empty "now" is used