the problem of translating words in the woocommerce subscription plugin

Viewed 35

until now, i had no problem translating words using gettext filter, now i want to translate some words of woocommerce subscription plugin, it is as follows :

<?php echo esc_html_x( 'Next payment', 'table heading', 'woocommerce-subscriptions' ); ?>

i want to translate it using the following code, but it does not translate

function customize_gettext( $translated, $untranslated ) {
    if ( $untranslated == 'Next payment' ) {
        $translated = __( 'text', 'woocommerce-subscriptions' );
    }
    return $translated;
} add_filter( 'gettext', 'customize_gettext', 97, 3 );

where is the problem with my work? Thank you for guiding me

1 Answers

after more effort, i got the result, i should have used gettext_with_context instead of gettext

function customize_gettext( $translated, $untranslated ) {
        if ( $untranslated == 'Next payment' ) {
            $translated = __( 'text', 'woocommerce-subscriptions' );
        }
        return $translated;
    } add_filter( 'gettext_with_context', 'customize_gettext', 10, 4 );
Related