title: How can I localize string inside function?
body: <p>I'm having some problems figuring out how to localize the string this function returns. What is the correct way of making strings translatable inside a function?</p>
  
  <pre><code>add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2);
  function add_search_box_to_menu( $items, $args ) {
      if( $args-&gt;theme_location == 'mobile' )
          return $items."&lt;li class='menu-header-search'&gt;&lt;form id='searchform' method='get'&gt;&lt;input type='text' name='s' id='s' placeholder='This placeholder text should be translatable'&gt;&lt;/form&gt;&lt;/li&gt;";
  
      return $items;
  }
  </code></pre>
  
  <p>This is the method which I initially thought would work, but didn't:</p>
  
  <pre><code>&lt;li class='menu-header-search'&gt;&lt;form id='searchform' method='get'&gt;&lt;input type='text' name='s' id='s' placeholder='" . __('This placeholder text should be translatable', 'my_textdomain') . "'&gt;&lt;/form&gt;&lt;/li&gt;";
  </code></pre>