[wp-trac] [WordPress Trac] #45528: load_script_textdomain() doesn't load translations when WP installed in a subdirectory with custom content dir

WordPress Trac noreply at wordpress.org
Sat Dec 8 00:38:42 UTC 2018


#45528: load_script_textdomain() doesn't load translations when WP installed in a
subdirectory with custom content dir
-------------------------------------------------+-------------------------
 Reporter:  fierevere                            |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  5.0.1
Component:  I18N                                 |     Version:  5.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-screenshots needs-unit-tests     |     Focuses:
  has-patch                                      |
-------------------------------------------------+-------------------------

Comment (by tmatsuur):

 Replying to [comment:10 fierevere]:
 > {{{
 > ( ! isset( $src_url['host'] ) || $src_url['host'] ===
 $content_url['host'] )
 >
 > }}}
 >
 > this didnt helped too.
 >
 > {{{
 >         // If the source is not from WP.
 >         if ( false === $relative ) {
 >                 return false;
 >         }
 >
 > }}}
 >
 > function exiting here with $relative === false

 In my environment it works with this.

 {{{
 if (
         strpos( $src_url['path'], $content_url['path'] ) === 0 &&
 //      ( ! isset( $src_url['host'] ) || $src_url['host'] !==
 $content_url['host'] )
         ( ! isset( $src_url['host'] ) || $src_url['host'] ===
 $content_url['host'] )
 ) {
         // Make the src relative the specific plugin or theme.
 //      $relative = trim( substr( $src, strlen( $content_url['path'] ) ),
 '/' );
         $relative = trim( substr( $src_url['path'], strlen(
 $content_url['path'] ) ), '/' );

 }}}

 If $src is `http://localhost/wp-
 content/plugins/myplugin/assets/js/comon.js`,
 $relative is `assets/js/common.js`.

 And the translation file `myplugin-ja-
 4a9aafdf461c74b88a1c7041526ae1d6.json` is successfully loaded.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45528#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list