 Hey there, and welcome to Learn WordPress. In this tutorial, you're going to learn about the internationalization in your WordPress plugins and themes. You will learn what internationalization is, what it isn't, why it's important, and how to implement it in your WordPress code. Internationalization is the process of developing your application in a way that it can be easily translated into other languages. Internationalization is often abbreviated as I-18N, because there are 18 letters between the letters I and N. WordPress is used all over the world by people who speak many languages. Therefore, any text strings in WordPress need to be coded so that they can be easily translated into those languages. The process of making sure your text strings can be translated is called internationalization. While the process of translating and adapting the strings to a specific language or location is called localization. While localization is outside of the scope of this tutorial, you can read more about it in the localization section of the Common API Handbook under internationalization. As a developer, you might not be able to provide localization for all your users. However, using the internationalization functions and tools to create specific files, a translator can successfully localize your code without needing to modify the source code itself. Internationalization is not the same as making sure your content is available in multiple languages on the front end of your website. This is more commonly referred to as making sure your content is multilingual or translated. Because the content is stored in the database, it's better to have a fully translated copy of your site content for each language you want to support. This can be achieved using plugins like translate press, polylang, or Weglot. Whenever you find yourself writing a string of text that will be displayed to the user, you should use the WordPress internationalization functions to make sure it can be translated. There are a number of internationalization functions available with each performing a different task related to internationalization. Let's look at the most basic function, the double underscore function. This function takes a string of text and returns the translated version of that string. If no translation is available, it returns the original string. You will also notice that this function, like most other internationalization functions, takes a second parameter. This parameter is used to specify the text domain. The text domain is a unique identifier for your plugin and theme. It is used to make sure that the correct translation files are loaded. To see how this works, let's take a look at an example inside a child theme of 2023. In the functions.php file, a JavaScript file is enqueued in the context of the WordPress dashboard. It also registers a submenu item in the appearance menu which renders a child theme settings page. The settings page contains a button which when clicked shows an alert. The code for this alert is handed in the JavaScript file enqueued for the theme. In this code, you have a number of English text strings that need to be made translatable. The first step is to internationalize the text strings in the PHP code. To do this, you can wrap the text strings in the double underscore function, specifying the text domain. Start by updating the text strings in the add submenu page function. So we will take this one here, use the double underscore function and specify the text domain, which we will keep the same as 2023 child. And we can use the same translation for the next piece of text. And that has been done. You can do the same for the text strings in the display page function. So here we need to open up our PHP tags and call the function past the text domain. And then because this is being translated, we need to echo the string out. And then we can do the same for piece of text at the bottom and format that code. Wordpress also contains a shorthand function to echo a translated string. This function is the underscore E function. It both translates and echoes the string. You can use this function here to simplify your code. So instead of the echo, we can say underscore E there, do the same there. Now you need to internationalize the text strings in the JavaScript file. Do this, there is a JavaScript equivalent to the PHP double underscore function, which is available in the WPI 18N object on the WordPress front end. To ensure that you can use this function, you need to set up your plugin and theme JavaScript localization. To do this, you update your NQ scripts function to require the WPI 18N package as a dependency. This will ensure that your JavaScript code is only loaded when the WPI 18N package is loaded and the object is available. In the functions of PHP, where the empty dependency array is, you can add that dependency. Then you need to call the WPI set script translations function for the script you want to translate. This function takes the handle of the script and the text domain as parameters. This will load the translations for the script. If we take this code, there we can pop that in there and pass in the script handle and the text domain. With this done, you can then use the double underscore function to translate the text string in your JavaScript file. So over here, we can say double underscore and specify the text domain, which is 2023 child and there we go. Unfortunately, you can't test this in the dashboard because if everything worked, you'll still see the same strings you saw before you made them translatable. What you can do is test this by generating a pot file. This is a file that a translator would use to create the translation files. You can generate this file using the WPCLI I18n make pot command. Inside the terminal in your WordPress site, you can run WPCI18n make pot and pass it the path to your plugin or theme. This will scan the code in your plugin or theme, find any translatable strings and place them in the pot file. And if you take a look at that file, you will see all of the strings that you have made translatable. It is important to follow best practices when internationalizing your code and internationalization in the common API section of the WordPress developer resources. There is a page on internationalization guidelines which is good to be familiar with. Additionally, if you plan to submit a theme to the WordPress theme directory, you should read the section on language and internationalization in the theme review handbook. This has been a brief introduction to internationalization in a WordPress plugin or theme. For more information, make sure to read the internationalization chapter in the common API's handbook on the WordPress developer resources. Happy coding.