Modifying shortcode output for translation
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.
Getting ready
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 (ch12/ch12-hello-world/ch12-hello-world-v2.php
) for that recipe from the book's GitHub page and rename the file to ch12-hello-world.php
.
How to do it...
Follow these steps to translate shortcode output before it is displayed and learn how to deal with variable data elements that can be positioned differently between languages:
- Navigate to the
ch12-hello-world
folder of the WordPress plugin directory of your development installation. - Open the
ch12...