Conditional Shortcode Based on Language

Things like emails sent to users by different plugins can not be translated because they do not appear in the front-end.

For these other types of content you can display content based on language using the shortcode:

[trp_language language="en_US"] English content only [/trp_language]

This can be done also with PHP:


$current_language = get_locale();

if( $current_language == 'en_EN' ){
echo 'text in language en_EN';
if( $current_language == 'fr_FR' ){
echo 'text in language fr_FR';


Another use case of the conditional shortcode is for translating images, basically displaying different images for different languages.

[trp_language language="en_US"] 
<img src="" /> [/trp_language]
[trp_language language="fr_FR"]
<img src="" />

However, this can now be easily achieved directly from the front-end using the built in image translation functionality.