Title: admin_enqueue_scripts hook &amp; internationalization
Last modified: August 21, 2016

---

# admin_enqueue_scripts hook & internationalization

 *  [websupporter](https://wordpress.org/support/users/websupporter/)
 * (@websupporter)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/admin_enqueue_scripts-hook-internationalisation/)
 * Hi everyone,
    I am currently struggeling with a small problem. Well, I’ve coded
   a workaround, but I am not very happy about it and I would appreciate your thoughts
   on this.
 * I am programming a plugin, which supports internationalization. This plugin adds
   also menus on the Adminpage. For the dashboard I run the following functions:
    - add_menu_page()
    - The action hook “admin_enqueue_scripts”
 * So, this is what happens:
    `add_menu_page( __( 'Menu Title', 'textdomain' ), 
   __( 'Menu Title', 'textdomain' ), 'edit_posts', 'slug', 'admin_output_index',
   SF_URL . 'icon.png', 81 );`
 * I add a menupage with the translateable Title ‘Menu Title’. And I add some submenupages.
 * In order to load my styles and Javascripts only on my menupage und subpages I
   use the action hook “admin_enqueue_scripts”:
 *     ```
       add_action( 'admin_enqueue_scripts', 'adminscripts' );
       function adminscripts( $hook ){
       	if( !in_array( $hook, array( 'toplevel_page_menu-title' ) ) )
       		return;
       	/* Register Scripts and Styles */
       }
       ```
   
 * The $hook tells me, wether I am on one of my adminpages or not. My hooks are 
   placed in an array. If the hook is not found in this array, my scripts and styles
   won’t load.
 * I’ve expected this hook to be stable, but it isn’t when it comes to internationalization,
   because part of the hook derives from the second “add_menu_page”-Parameter:
    `_('
   Menu Title', 'textdomain' )`
 * So, in the moment, I run this script on another language, the hook changes and
   my scripts doesn’t load. For now, my “workaround” is simply not to translate 
   the second parameter, but this is a rather poor solution.
 * I am not quite sure, wether I shall call this a “bug” in WordPress or if I do
   not quite understand the whole “hook”-idea. But, before I now start to open a
   ticket or report to the core developers, I think its better to discuss this here.
 * I am quite interested, what you guys think 🙂
 * All the best

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [websupporter](https://wordpress.org/support/users/websupporter/)
 * (@websupporter)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/admin_enqueue_scripts-hook-internationalisation/#post-4779974)
 * So, the central question I’ve got is the following:
 * /wp-admin/includes/plugin.php
    Line 983: `$admin_page_hooks[$menu_slug] = sanitize_title(
   $menu_title );`
 * Why? Why not:
    `$admin_page_hooks[$menu_slug] = sanitize_title( $menu_slug);`
 * I think this would solve my problem. Or does it need to be the internationalizable
   $menu_title for some reason?
 *  Thread Starter [websupporter](https://wordpress.org/support/users/websupporter/)
 * (@websupporter)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/admin_enqueue_scripts-hook-internationalisation/#post-4780137)
 * For everyone, who might be interested, its a reported bug:
    [https://core.trac.wordpress.org/ticket/18857](https://core.trac.wordpress.org/ticket/18857)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘admin_enqueue_scripts hook & internationalization’ is closed to new replies.

## Tags

 * [add_menu_page](https://wordpress.org/support/topic-tag/add_menu_page/)
 * [admin_enqueue_scripts](https://wordpress.org/support/topic-tag/admin_enqueue_scripts/)
 * [i18n](https://wordpress.org/support/topic-tag/i18n/)
 * [internationalization](https://wordpress.org/support/topic-tag/internationalization/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 1 participant
 * Last reply from: [websupporter](https://wordpress.org/support/users/websupporter/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/admin_enqueue_scripts-hook-internationalisation/#post-4780137)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
