• Resolved W★

    (@filmpuls)


    Query Monitor gives me this message: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wp-youtube-lyte domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. (Diese Meldung wurde in Version 6.7.0 hinzugefügt.)

    Any hint how to solve this is appreciated, thanks!

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    it’s on my radar but have not had the time to look into it yet (there’s no functional impact), if these notices bug you, you can use this code snippet (not mine) to stop these from being logged.

    Are we getting anywhere close to a solution to this issue? We have tons of clients who are reporting this specific issue. Thanks!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    not yet, sorry. I’d welcome help on this 🙂

    Hi Frank, love the plugin thanks! Here’s my two cents on it…

    Problem Example: In the plugin file player_sizes.inc.php, at the top of the file (around line 11), the plugin calls:

    __('Mini 16:9 player…', 'wp-youtube-lyte');

    But WordPress hasn’t fully initialized yet (specifically, translations haven’t been fully prepared), so any __() or _e() call happening too early will now trigger a notice in WordPress 6.7+.

    Potential Solution: We can’t defer loading the whole player_sizes.inc.php file until after WordPress is ready (preferably after init), because there are so many other things that early depend on those arrays that get defined in there. But if you remove all the translations aspect from that file…

    Eg. delete these lines:
    $plugin_dir = basename( dirname( __FILE__ ) ) . '/languages';
    load_plugin_textdomain( 'wp-youtube-lyte', false, $plugin_dir );

    and also replace each of these below ones...:
    $pSize[8]['t'] = __( 'Mini 16:9 player', 'wp-youtube-lyte' );
    $pSize[0]['t'] = __( 'Smaller 4:3 player', 'wp-youtube-lyte' );
    $pSize[1]['t'] = __( 'Smaller 16:9 player', 'wp-youtube-lyte' );
    $pSize[2]['t'] = __( 'Standard value, YouTube default for 4:3-ratio video', 'wp-youtube-lyte' );
    $pSize[3]['t'] = __( 'YouTube default for 16:9-ratio video', 'wp-youtube-lyte' );
    $pSize[4]['t'] = __( 'Larger 4:3 player', 'wp-youtube-lyte' );
    $pSize[5]['t'] = __( 'Larger 16:9 player', 'wp-youtube-lyte' );
    $pSize[6]['t'] = __( 'Maxi 4:3 player', 'wp-youtube-lyte' );
    $pSize[7]['t'] = __( 'Maxi 16:9 player', 'wp-youtube-lyte' );
    ...replace them with just the raw strings like this:
    $pSize[8]['t'] = 'Mini 16:9 player';
    $pSize[0]['t'] = 'Smaller 4:3 player';
    $pSize[1]['t'] = 'Smaller 16:9 player';
    $pSize[2]['t'] = 'Standard value, YouTube default for 4:3-ratio video';
    $pSize[3]['t'] = 'YouTube default for 16:9-ratio video';
    $pSize[4]['t'] = 'Larger 4:3 player';
    $pSize[5]['t'] = 'Larger 16:9 player';
    $pSize[6]['t'] = 'Maxi 4:3 player';
    $pSize[7]['t'] = 'Maxi 16:9 player';

    And then inside your main plugin file, wp-youtube-lyte.php you can wrap the translation aspects only, so they happen safely after WordPress init. For example…

    Cut out lines 65 and 66:
    $plugin_dir = basename( dirname( __FILE__ ) ) . '/languages';
    load_plugin_textdomain( 'wp-youtube-lyte', false, $plugin_dir );

    and add them back at line 68 with a whole little snippet like this to try handle the title translation after init has safely happened:

    /** translate size descriptions after init */
    add_action( 'init', function() {
    $plugin_dir = basename( dirname( __FILE__ ) ) . '/languages';
    load_plugin_textdomain( 'wp-youtube-lyte', false, $plugin_dir );
    global $pSize;
    if ( ! empty( $pSize ) ) {
    foreach ( $pSize as $key => $size ) {
    if ( isset( $size['t'] ) && is_string( $size['t'] ) ) {
    $pSize[$key]['t'] = __( $size['t'], 'wp-youtube-lyte' );
    }
    }
    }
    });

    Now I’m not sure how to actually test that this still works with the translation of those titles, but the error notices are gone, and everything else seems to still be working as it should, so hopefully this helps you in some way as a potential workaround?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    thanks for your input @joshmyself, the good news is an update is coming that does fix the translation loading issues 🙂

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    just released an update, should be OK now 🙂

    Thread Starter W★

    (@filmpuls)

    👍thank you

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

The topic ‘Translation loading’ is closed to new replies.