![]() ![]() Nothing is more annoying than using a theme or plugin where the author hard coded texts making it impossible to translate or change in any way. It’s good practice to make sure we cover absolutely all texts. The next step is going through all our code and find any text output that should be translatable. If WordPress doesn’t find the folder nor the correct translation files, it will default back to the texts we have in theme. We defined them to reside in a subfolder ‘ lang‘ in our theme directory.ĭon’t worry if this folder doesn’t exist or doesn’t contain any files – nothing will crash. The second argument tells WordPress where the translation files are. You will repeat this handle every time you make a text translatable. The first argument is the handle, this is an unique string which you will use to group up all texts that belongs to your theme. In case you forgot, this is what we added: load_theme_textdomain('wptutorial', get_stylesheet_directory(). We have already done the first part in the previous step of this theme tutorial series, where we added load_theme_textdomain in our theme’s setup function. If you are interested in the topic, WordPress Codex has a long and good documentation guide on i18n for developers. But it can also be utilized for changing certain texts to something different within the same language. This is very useful for people who want to use WordPress and your theme (or plugin) in a different language than the origin language it was written in (which is usually English). ![]() Inside your theme (or plugin) you can add files of a certain filetype for each translated language, or make sure other people are able to create their own translation in their own language. These functions make it so that WordPress is able to pick these up and inject a translation if it exists. The way it works is that you as a theme author or plugin developer wrap all your texts (such as “Read more”, “No posts”) in certain functions. This is called internationalization (i18n in short), and allows people to translate texts you add in your theme into another language. Why bother with adding translation support?Īll themes, at least ones that goes public for use of other people than the developer, should be available for translation. We will also learn how to set up PoEdit properly to create a translation file for our theme, ready to be translated into different languages. In this lesson we learn about how translation (or otherwise known as i18n) in WordPress works and how to make the necessary adjustments in our templates. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |