Internationalization In WordPress

215. Internationalization in WordPress

So, let’s see what’s Internationalization. It is the process of developing your theme, so it can easily be translated into other languages. Internationalization is often abbreviated as i18n (since there are 18 letters between the i and the n).

Translation

WordPress is used all over the world, and it’s great to prepare WordPress themes so that they may be easily translated into other languages. As a developer, you may not have much time providing localizations for all your users, but any translator can successfully localize the theme without modifying the source code itself.

If you want to make a string translatable in your application, you should wrap the original strings in a call to one of a set of special functions.

WordPress uses the gettext libraries and tools for i18n. If you look online, you’ll see the _() function, that refers to the native PHP gettext-compliant translation function, but instead with WordPress you should use the __() WordPress defined PHP function.

Domain

You should use a text domain in order to denote all text belonging to that theme. The text domain is a unique identifier, that ensures WordPress can distinguish between all loaded translations. This grows portability and plays better with already existing WordPress tools.

The text domain should match the slug of the theme. If your theme’s name “My Theme" is defined in the style.css or it is contained in a folder called “my-theme" the domain name must be “my-theme". The text domain name should use dashes and not underscores.

The text domain should also be added to the style.css header. WordPress uses it to internationalize your theme meta-data even when the theme is disabled, and the text domain should be same as the one used when loading the text domain.

This much guys! Hope this article was helpful for you!

Share this!

Post Author: Staff

Leave a Reply

Your email address will not be published. Required fields are marked *