LeKoala\Multilingual\LangHelper
i18n helper class
Synopsis
class LangHelper
{
- // constants
- const GLOBAL_ENTITY = 'Global';
- // members
- private static array $default_locales = ;
- private static boolean $persist_cookie = true;
- protected static array $locale_cache = ;
- // methods
- public static string globalTranslation()
- public static void persistLocaleIfCookiesAreAllowed()
- public static void persistLocale()
- public static void provisionLocales()
- public static string get_lang()
- public static string get_locale()
- public static string get_locale_from_lang()
- public static bool usesFluent()
- public static array get_available_langs()
- public static mixed withLocale()
- public static array withLocales()
Hierarchy
Uses
- SilverStripe\Core\Config\Configurable
Constants
Name | Value |
---|---|
GLOBAL_ENTITY | 'Global' |
Members
private
- $default_locales
—
array
Provision fluent locales defined in yml Use LangHelper::provisionLocales
protected
- $locale_cache — array
Methods
public
- get_available_langs()
- get_lang() — Make sure we get a proper two characters lang
- get_locale() — Get the right locale (using fluent data if exists)
- get_locale_from_lang() — Get a locale from the lang
- globalTranslation() — Get a global translation
- persistLocale() — Persist locale according to fluent settings
- persistLocaleIfCookiesAreAllowed() — Call this to make sure we are not setting any cookies that has not been accepted
- provisionLocales() — Provision locales defined in default_locales
- usesFluent() — Do we have the subsite module installed TODO: check if it might be better to use module manifest instead?
- withLocale() — Execute the callback in given subsite
- withLocales() — Execute the callback for all locales