Title: WP_Locale_Switcher::init
Published: December 6, 2016
Last modified: May 20, 2026

---

# WP_Locale_Switcher::init()

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#wp--skip-link--target)

Initializes the locale switcher.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#description)󠁿

Hooks into the [‘locale’](https://developer.wordpress.org/reference/hooks/locale/)
and [‘determine_locale’](https://developer.wordpress.org/reference/hooks/determine_locale/)
filters to change the locale on the fly.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#source)󠁿

    ```php
    public function init() {
    	add_filter( 'locale', array( $this, 'filter_locale' ) );
    	add_filter( 'determine_locale', array( $this, 'filter_locale' ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-locale-switcher.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-locale-switcher.php#L61)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-locale-switcher.php#L61-L64)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#related)󠁿

| Uses | Description | 
| [add_filter()](https://developer.wordpress.org/reference/functions/add_filter/)`wp-includes/plugin.php` |

Adds a callback function to a filter hook.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_locale_switcher/init/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_locale_switcher%2Finit%2F)
before being able to contribute a note or feedback.