WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Translate shortcode text (3 posts)

  1. jasonsweb
    Member
    Posted 1 year ago #

    Hi,

    Is it possible to add a translation/text domain to a shortcode?
    In my theme I use the standard code to translate a line, like:
    <?php _e('Hello, this is text', 'domain'); ?>

    But how can I implement this into my shortcode with a domain?
    Like:

    $shortcode .= '<span>Hello, this text should be translated.</span>';
    return $shortcode;

    Thanks in advance.

  2. shahar
    Member
    Posted 1 year ago #

    Hi jasonsweb, you can do it like this:

    $shortcode .= '<span>' . __( 'Hello, this text should be translated', 'domain' ) . '</span>';
    return $shortcode;
  3. jasonsweb
    Member
    Posted 1 year ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic