As we have seen in numerous recipes, shortcodes are powerful tools that provide an easy way for users to add content to their website posts and pages. Since this content is presented to users, it can benefit from a translation just as much as the website's administration pages.
This recipe shows how to translate shortcode output before it is displayed. It also explains how to deal with variable data elements that can be positioned differently between languages.
You should have already followed the Making admin page code ready for translation recipe to have a starting point for this recipe. Alternatively, you can get the resulting code (
Chapter 11/ch11-hello-world/ch11-hello-world-v2.php) for that recipe from the code bundle. You should rename the file to
ch11-hello-world.php before starting.