Title: wp_set_lang_dir
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_set_lang_dir()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_set_lang_dir/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/functions/wp_set_lang_dir/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_set_lang_dir/?output_format=md#changelog)

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Sets the location of the language directory.

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

To set directory manually, define the `WP_LANG_DIR` constant in wp-config.php.

If the language directory exists within `WP_CONTENT_DIR`, it is used. Otherwise 
the language directory is assumed to live in `WPINC`.

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

    ```php
    function wp_set_lang_dir() {
    	if ( ! defined( 'WP_LANG_DIR' ) ) {
    		if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' )
    			|| ! @is_dir( ABSPATH . WPINC . '/languages' )
    		) {
    			/**
    			 * Server path of the language directory.
    			 *
    			 * No leading slash, no trailing slash, full path, not relative to ABSPATH
    			 *
    			 * @since 2.1.0
    			 */
    			define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );

    			if ( ! defined( 'LANGDIR' ) ) {
    				// Old static relative path maintained for limited backward compatibility - won't work in some cases.
    				define( 'LANGDIR', 'wp-content/languages' );
    			}
    		} else {
    			/**
    			 * Server path of the language directory.
    			 *
    			 * No leading slash, no trailing slash, full path, not relative to `ABSPATH`.
    			 *
    			 * @since 2.1.0
    			 */
    			define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' );

    			if ( ! defined( 'LANGDIR' ) ) {
    				// Old relative path maintained for backward compatibility.
    				define( 'LANGDIR', WPINC . '/languages' );
    			}
    		}
    	}
    }
    ```

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

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

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

## User Contributed Notes

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