LocaleTestTrait
Define helpers for testing multiple locales.
Ex: Multilingual test with try/finally try { $this->enableMultilingual(['en_US' => 'fr_CA']); $this->assert(...); } finally { $this->disbleMultilingual(); }
Ex: Multilingual with auto-clean $cleanup = $this->useMultilingual(['en_US' => 'fr_CA']);
Table of Contents
Methods
- disableMultilingual() : void
- enableMultilingual() : void
- Enable multilingual.
- useMultilingual() : CRM_Utils_AutoClean
- Temporarily use multilingual.
- getDefaultSystemLocale() : string
- Get the default system locale.
Methods
disableMultilingual()
public
disableMultilingual() : void
enableMultilingual()
Enable multilingual.
public
enableMultilingual([array<string|int, mixed>|null $addLocales = NULL ]) : void
Parameters
- $addLocales : array<string|int, mixed>|null = NULL
-
A list of new locales to setup. A locale is initialized by copying from an existing locale.
Ex: Copy from en_US to fr_CA ['en_US' => 'fr_CA'] Ex: Copy from en_US to fr_CA and de_DE ['en_US' => ['fr_CA', 'de_DE]]
useMultilingual()
Temporarily use multilingual.
public
useMultilingual(array<string|int, mixed> $addLocales) : CRM_Utils_AutoClean
Parameters
- $addLocales : array<string|int, mixed>
-
A list of new locales to setup. A locale is initialized by copying from an existing locale.
Ex: Copy from en_US to fr_CA ['en_US' => 'fr_CA'] Ex: Copy from en_US to fr_CA and de_DE ['en_US' => ['fr_CA', 'de_DE]]
Return values
CRM_Utils_AutoClean —A reference to the temporary configuration. Once removed, the system will revert to single language.
getDefaultSystemLocale()
Get the default system locale.
protected
getDefaultSystemLocale() : string