[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Locale API: WP_Locale_Switcher class
File Size: | 297 lines (7 kb) |
Included or required: | 1 time |
Referenced: | 0 times |
Includes or requires: | 0 files |
WP_Locale_Switcher:: (12 methods):
__construct()
init()
switch_to_locale()
switch_to_user_locale()
restore_previous_locale()
restore_current_locale()
is_switched()
get_switched_locale()
get_switched_user_id()
filter_locale()
load_translations()
change_locale()
Class: WP_Locale_Switcher - X-Ref
Core class used for switching locales.__construct() X-Ref |
Constructor. Stores the original locale as well as a list of all available languages. |
init() X-Ref |
Initializes the locale switcher. Hooks into the {@see 'locale'} and {@see 'determine_locale'} filters to change the locale on the fly. |
switch_to_locale( $locale, $user_id = false ) X-Ref |
Switches the translations according to the given locale. param: string $locale The locale to switch to. param: int|false $user_id Optional. User ID as context. Default false. return: bool True on success, false on failure. |
switch_to_user_locale( $user_id ) X-Ref |
Switches the translations according to the given user's locale. param: int $user_id User ID. return: bool True on success, false on failure. |
restore_previous_locale() X-Ref |
Restores the translations according to the previous locale. return: string|false Locale on success, false on failure. |
restore_current_locale() X-Ref |
Restores the translations according to the original locale. return: string|false Locale on success, false on failure. |
is_switched() X-Ref |
Whether switch_to_locale() is in effect. return: bool True if the locale has been switched, false otherwise. |
get_switched_locale() X-Ref |
Returns the locale currently switched to. return: string|false Locale if the locale has been switched, false otherwise. |
get_switched_user_id() X-Ref |
Returns the user ID related to the currently switched locale. return: int|false User ID if set and if the locale has been switched, false otherwise. |
filter_locale( $locale ) X-Ref |
Filters the locale of the WordPress installation. param: string $locale The locale of the WordPress installation. return: string The locale currently being switched to. |
load_translations( $locale ) X-Ref |
Load translations for a given locale. When switching to a locale, translations for this locale must be loaded from scratch. param: string $locale The locale to load translations for. |
change_locale( $locale ) X-Ref |
Changes the site's locale to the given one. Loads the translations, changes the global `$wp_locale` object and updates all post type labels. param: string $locale The locale to change to. |
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |