Last active
November 13, 2017 07:56
-
-
Save tacoverdo/2ffad5693b9532305a41 to your computer and use it in GitHub Desktop.
What is the best way to translate a text with hyperlink?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// METHOD 1 | |
sprintf( __( 'Please read %1$sthis%2$s.', 'tacoverdo-example-domain' ), '<a target="_blank" href="' . esc_url( 'https://goo.gl' ) . '">', '</a>' ); | |
// METHOD 2 | |
echo '<a target="_blank" href="' . esc_url( 'https://goo.gl' ) . '">'; | |
__( 'Please read this.', 'tacoverdo-example-domain' ); | |
echo '</a>'; | |
// METHOD 3 | |
sprintf( __( 'Please read <a href="%s">this</a>.', 'tacoverdo-example-domain' ), esc_url( 'https://goo.gl' ) ); | |
// METHOD 4 | |
sprintf( __( 'Please read %sthis%s.', 'tacoverdo-example-domain' ), '<a target="_blank" href="' . esc_url( 'https://goo.gl' ) . '">', '</a>' ); | |
// METHOD 5 | |
__( 'Please read <a target="_blank" href="' . esc_url( 'https://goo.gl' ) . '">this</a>', 'tacoverdo-example-domain' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please continue discussion here, if necessary.
Thanks!