wp_set_lang_dir

The timeline below displays how wordpress function wp_set_lang_dir has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Sets the location of the language directory.
 *
 * 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`.
 *
 * @since 3.0.0
 * @access private
 */
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');
            }
        }
    }
}

WordPress Version: 4.6

/**
 * Set the location of the language directory.
 *
 * 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`.
 *
 * @since 3.0.0
 * @access private
 */
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');
            }
        }
    }
}

WordPress Version: 4.0

/**
 * Set the location of the language directory.
 *
 * 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`.
 *
 * @since 3.0.0
 * @access private
 */
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 backwards 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 backwards compatibility
                define('LANGDIR', WPINC . '/languages');
            }
        }
    }
}

WordPress Version: 3.7

/**
 * Sets the location of the language directory.
 *
 * To set directory manually, define <code>WP_LANG_DIR</code> in wp-config.php.
 *
 * If the language directory exists within WP_CONTENT_DIR, that is used.
 * Otherwise if the language directory exists within WPINC, that's used.
 * Finally, if neither of the preceding directories are found,
 * WP_CONTENT_DIR/languages is used.
 *
 * The WP_LANG_DIR constant was introduced in 2.1.0.
 *
 * @access private
 * @since 3.0.0
 */
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')) {
            define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages');
            // no leading slash, no trailing slash, full path, not relative to ABSPATH
            if (!defined('LANGDIR')) {
                // Old static relative path maintained for limited backwards compatibility - won't work in some cases
                define('LANGDIR', 'wp-content/languages');
            }
        } else {
            define('WP_LANG_DIR', ABSPATH . WPINC . '/languages');
            // no leading slash, no trailing slash, full path, not relative to ABSPATH
            if (!defined('LANGDIR')) {
                // Old relative path maintained for backwards compatibility
                define('LANGDIR', WPINC . '/languages');
            }
        }
    }
}