From the course: WordPress: Internationalization

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Working with plurals

Working with plurals

- [Instructor] Plurals come into play when you have a string that changes with a number of items. A basic example of this in WordPress is the comment. In English, we have one comment where comment is singular, or two comments where comments is plural. When working with strings for translation, we need to allow translators a way to adjust these strings based on that number. In this case, comment versus comments. To help us with that, we've got the _n function. This function grabs the plural, or singular form based on the quantity. Let's take a look at this function in the WordPress docs. So the function takes four parameters. First, we've got the single version of the string, which is the text that'll be used if the number is singular. Then we've got the plural version and then we have whatever the number actually is. And finally, our text domain. So let's look at an example. Using comments, I'm going to say _n or I should…

Contents