In order to make a string translatable in your code, it needs to be wrapped in the appropriate gettext function. WordPress has its own function you should use instead of gettext(). Learn about the two most common string translations available in WordPress and see examples of how you would use them in PHP.
- [Voiceover] In order to make a string translatable…in your code, you need to wrap it…in a special gettext function.…If you go to the PHP manual for gettext,…we can see exactly what this function looks like.…The name of the function is gettext,…and it's a datatype of string, and it accepts one parameter,…which is message, and it's also the datatype of string.…Now this function also has a shorter alias,…which is just the underscore parentheses instead…of the gettext parentheses.…In WordPress you're not gonna use either one of these,…because WordPress has it's own function…for translating strings.…
Here's a page for showing all of the available…translation functions in WordPress.…The equivalent to what we just looked at…with the gettext parentheses…is this double underscore parentheses.…This double underscore function is the most common…translation function you'll see.…Note that depending on what font you're using…in your code editor, that double underscore…may look like two distinct underscores,…or sort of run together into one line.…
- Why internationalization is important
- Using the gettext() function
- Adding context for translations
- Adding and loading text domains for WordPress themes and plugins
- Translating using GlotPress