Title: WP_Textdomain_Registry::get_path_from_lang_dir
Published: November 2, 2022
Last modified: August 20, 2026

---

# WP_Textdomain_Registry::get_path_from_lang_dir( string $domain, string $locale ): string|false

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_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.

Gets the path to the language directory for the current domain and locale.

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

Checks the plugins and themes language directories as well as any custom directory
set via [load_plugin_textdomain()](https://developer.wordpress.org/reference/functions/load_plugin_textdomain/)
or [load_theme_textdomain()](https://developer.wordpress.org/reference/functions/load_theme_textdomain/).

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#see-also)󠁿

 * [_get_path_to_translation_from_lang_dir()](https://developer.wordpress.org/reference/functions/_get_path_to_translation_from_lang_dir/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#parameters)󠁿

 `$domain`stringrequired

Text domain.

`$locale`stringrequired

Locale.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_path_from_lang_dir/?output_format=md#return)󠁿

 string|false Language directory path or false if there is none available.

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

    ```php
    private function get_path_from_lang_dir( $domain, $locale ) {
    	$locations = $this->get_paths_for_domain( $domain );

    	$found_location = false;

    	foreach ( $locations as $location ) {
    		$files = $this->get_language_files_from_path( $location );

    		$mo_path  = "$location/$domain-$locale.mo";
    		$php_path = "$location/$domain-$locale.l10n.php";

    		foreach ( $files as $file_path ) {
    			if (
    				! in_array( $domain, $this->domains_with_translations, true ) &&
    				str_starts_with( str_replace( "$location/", '', $file_path ), "$domain-" )
    			) {
    				$this->domains_with_translations[] = $domain;
    			}

    			if ( $file_path === $mo_path || $file_path === $php_path ) {
    				$found_location = rtrim( $location, '/' ) . '/';
    				break 2;
    			}
    		}
    	}

    	if ( $found_location ) {
    		$this->set( $domain, $locale, $found_location );

    		return $found_location;
    	}

    	/*
    	 * If no path is found for the given locale and a custom path has been set
    	 * using load_plugin_textdomain/load_theme_textdomain, use that one.
    	 */
    	if ( isset( $this->custom_paths[ $domain ] ) ) {
    		$fallback_location = rtrim( $this->custom_paths[ $domain ], '/' ) . '/';
    		$this->set( $domain, $locale, $fallback_location );
    		return $fallback_location;
    	}

    	$this->set( $domain, $locale, false );

    	return false;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-textdomain-registry.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-textdomain-registry.php#L313)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-textdomain-registry.php#L313-L358)

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

| Uses | Description | 
| [WP_Textdomain_Registry::get_language_files_from_path()](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_language_files_from_path/)`wp-includes/class-wp-textdomain-registry.php` |

Retrieves translation files from the specified path.

  | 
| [WP_Textdomain_Registry::get_paths_for_domain()](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get_paths_for_domain/)`wp-includes/class-wp-textdomain-registry.php` |

Returns possible language directory paths for a given text domain.

  | 
| [WP_Textdomain_Registry::set()](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/set/)`wp-includes/class-wp-textdomain-registry.php` |

Sets the language directory path for a specific domain and locale.

  |

| Used by | Description | 
| [WP_Textdomain_Registry::get()](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/get/)`wp-includes/class-wp-textdomain-registry.php` |

Returns the languages directory path for a specific domain and locale.

  |

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

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

## User Contributed Notes

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