Title: load_script_translations
Published: January 14, 2019
Last modified: May 20, 2026

---

# load_script_translations( string|false $file, string $handle, string $domain ): string|false

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/load_script_translations/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/load_script_translations/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/load_script_translations/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/load_script_translations/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/load_script_translations/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/load_script_translations/?output_format=md#changelog)

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

Loads the translation data for the given script handle and text domain.

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

 `$file`string|falserequired

Path to the translation file to load. False if there isn’t one.

`$handle`stringrequired

Name of the script to register a translation domain to.

`$domain`stringrequired

The text domain.

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

 string|false The JSON-encoded translated strings for the given script handle and
text domain.
 False if there are none.

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

    ```php
    function load_script_translations( $file, $handle, $domain ) {
    	/**
    	 * Pre-filters script translations for the given file, script handle and text domain.
    	 *
    	 * Returning a non-null value allows to override the default logic, effectively short-circuiting the function.
    	 *
    	 * @since 5.0.2
    	 *
    	 * @param string|false|null $translations JSON-encoded translation data. Default null.
    	 * @param string|false      $file         Path to the translation file to load. False if there isn't one.
    	 * @param string            $handle       Name of the script to register a translation domain to.
    	 * @param string            $domain       The text domain.
    	 */
    	$translations = apply_filters( 'pre_load_script_translations', null, $file, $handle, $domain );

    	if ( null !== $translations ) {
    		return $translations;
    	}

    	/**
    	 * Filters the file path for loading script translations for the given script handle and text domain.
    	 *
    	 * @since 5.0.2
    	 *
    	 * @param string|false $file   Path to the translation file to load. False if there isn't one.
    	 * @param string       $handle Name of the script to register a translation domain to.
    	 * @param string       $domain The text domain.
    	 */
    	$file = apply_filters( 'load_script_translation_file', $file, $handle, $domain );

    	if ( ! $file || ! is_readable( $file ) ) {
    		return false;
    	}

    	$translations = file_get_contents( $file );

    	/**
    	 * Filters script translations for the given file, script handle and text domain.
    	 *
    	 * @since 5.0.2
    	 *
    	 * @param string $translations JSON-encoded translation data.
    	 * @param string $file         Path to the translation file that was loaded.
    	 * @param string $handle       Name of the script to register a translation domain to.
    	 * @param string $domain       The text domain.
    	 */
    	return apply_filters( 'load_script_translations', $translations, $file, $handle, $domain );
    }
    ```

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

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/load_script_translations/?output_format=md#hooks)󠁿

 [apply_filters( ‘load_script_translations’, string $translations, string $file, string $handle, string $domain )](https://developer.wordpress.org/reference/hooks/load_script_translations/)

Filters script translations for the given file, script handle and text domain.

 [apply_filters( ‘load_script_translation_file’, string|false $file, string $handle, string $domain )](https://developer.wordpress.org/reference/hooks/load_script_translation_file/)

Filters the file path for loading script translations for the given script handle
and text domain.

 [apply_filters( ‘pre_load_script_translations’, string|false|null $translations, string|false $file, string $handle, string $domain )](https://developer.wordpress.org/reference/hooks/pre_load_script_translations/)

Pre-filters script translations for the given file, script handle and text domain.

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

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

Calls the callback functions that have been added to a filter hook.

  |

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

Resolves and loads the translation JSON file for a given script or script module source URL.

  |

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

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

## User Contributed Notes

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