[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-locale-switcher.php (summary)

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

Defines 1 class

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.

return: bool True on success, false on failure.
param: string    $locale  The locale to switch to.
param: int|false $user_id Optional. User ID as context. Default false.

switch_to_user_locale( $user_id )   X-Ref
Switches the translations according to the given user's locale.

return: bool True on success, false on failure.
param: int $user_id User ID.

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.

return: string The locale currently being switched to.
param: string $locale The locale of the WordPress installation.

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 : Tue Apr 23 08:20:01 2024 Cross-referenced by PHPXref