Adapting default user settings for translation
Before we can create translation files for our own plugins, their code needs to be specifically written to allow text items to be translated. This work starts in the plugin's activation routine, where default plugin option values are set. By using translation functions, our code can search for alternate values when a language other than English is specified in the website's configuration file.
Getting ready
You should have already followed the Changing the WordPress site language configuration recipe to have configured a language other than English for your development site.
How to do it...
Follow these steps to assign a translated string to a plugin's default options array on initialization:
- Navigate to the WordPress
plugins
directory of your development installation. - Create a new directory called
ch12-hello-world
. - Navigate to the directory and create a text file called
ch12-hello-world.php
. ...