CRM_Core_I18n
class CRM_Core_I18n
Constants
NONE |
Constants for communication preferences. |
AUTO |
Constants for communication preferences. |
Properties
static callable|null | $SQL_ESCAPER |
Methods
Encode a string for use in SQL.
A locale-based constructor that shouldn't be called from outside of this class (use singleton() instead).
Returns whether gettext is running natively or using PHP-Gettext.
Set native locale for getText.
Set getText locale.
Return languages available in this instance of CiviCRM.
Return the available UI languages
Replace arguments in a string with their values. Arguments are represented by % followed by their number.
Get the directory for l10n resources.
Smarty block function, provides gettext support for smarty.
Lookup the raw translation of a string (without any extra escaping or interpolation).
Translate a string to the current locale.
Localize (destructively) array values.
Localize (destructively) array elements with keys of 'title'.
Binds a gettext domain, wrapper over bindtextdomain().
Is the CiviCRM in multilingual mode.
Is the language written "right-to-left"?
Change the processing language without changing the current user language
Static instance provider - return the instance for the current locale.
Set the LC_TIME locale if it's not set already (for a given language choice).
Get the default language for contacts where no language is provided.
Get the current locale
Details
at line 62
static protected string
escapeSql(string $text)
Encode a string for use in SQL.
at line 105
CRM_Core_I18n
__construct(string $locale)
A locale-based constructor that shouldn't be called from outside of this class (use singleton() instead).
at line 127
bool
isNative()
Returns whether gettext is running natively or using PHP-Gettext.
at line 136
protected
setNativeGettextLocale(string $locale)
Set native locale for getText.
at line 160
protected
setPhpGettextLocale(string $locale)
Set getText locale.
at line 190
static array
languages(bool $justEnabled = FALSE)
Return languages available in this instance of CiviCRM.
at line 252
static array|string
uiLanguages($justCodes = FALSE)
Return the available UI languages
at line 278
string
strarg(string $str)
Replace arguments in a string with their values. Arguments are represented by % followed by their number.
at line 300
static string
getResourceDir()
Get the directory for l10n resources.
at line 334
string
crm_translate(string $text, array $params = [])
Smarty block function, provides gettext support for smarty.
The block content is the text that should be translated.
Any parameter that is sent to the function will be represented as %n in the translation text, where n is 1 for the first parameter. The following parameters are reserved: - escape - sets escape mode: - 'html' for HTML escaping, this is the default. - 'js' for javascript escaping. - 'no'/'off'/0 - turns off escaping - plural - The plural version of the text (2nd parameter of ngettext()) - count - The item count for plural mode (3rd parameter of ngettext()) - context - gettext context of that string (for homonym handling)
at line 432
protected string
crm_translate_raw(string $text, string|null $domain, int|null $count, string $plural, string $context)
Lookup the raw translation of a string (without any extra escaping or interpolation).
at line 522
string
translate(string $string)
Translate a string to the current locale.
at line 534
localizeArray(array $array, array $params = [])
Localize (destructively) array values.
at line 557
localizeTitles(array $array)
Localize (destructively) array elements with keys of 'title'.
at line 578
Bool
setGettextDomain($key)
Binds a gettext domain, wrapper over bindtextdomain().
at line 632
static Bool
isMultilingual()
Is the CiviCRM in multilingual mode.
at line 647
static Bool
isLanguageRTL($language)
Is the language written "right-to-left"?
at line 661
setLocale($locale)
Change the processing language without changing the current user language
at line 692
static CRM_Core_I18n
singleton()
Static instance provider - return the instance for the current locale.
at line 710
static string
setLcTime()
Set the LC_TIME locale if it's not set already (for a given language choice).
at line 732
static string
getContactDefaultLanguage()
Get the default language for contacts where no language is provided.
Note that NULL is a valid option so be careful with checking for empty etc.
NULL would mean 'we don't know & we don't want to hazard a guess'.
at line 755
static string
getLocale()
Get the current locale