Title: WP_Locale_Switcher::__construct
Published: December 6, 2016
Last modified: April 28, 2025

---

# WP_Locale_Switcher::__construct()

## In this article

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

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

Constructor.

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

Stores the original locale as well as a list of all available languages.

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

    ```php
    public function __construct() {
    	$this->original_locale     = determine_locale();
    	$this->available_languages = array_merge( array( 'en_US' ), get_available_languages() );
    }
    ```

[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/6.9.4/src/wp-includes/class-wp-locale-switcher.php#L48)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-locale-switcher.php#L48-L51)

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

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

Determines the current locale desired for the request.

  | 
| [get_available_languages()](https://developer.wordpress.org/reference/functions/get_available_languages/)`wp-includes/l10n.php` |

Gets all available languages based on the presence of *.mo and *.l10n.php files in a given directory.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_locale_switcher/__construct/?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%2F__construct%2F)
before being able to contribute a note or feedback.