I read one place that if you are using
__()
, ande()
throughout,
you do not need a plugin like WPML.
This is not accurate. Those functions and WPML are for two different things.
With a WordPress site you have two kinds of text that might need to be translated:
- Content. That is any text entered into WordPress as content that is stored in the database. This includes the body of posts and pages, but also titles, widgets and menus etc.
- Template strings. This refers to pieces of text that are coded into templates and functions. For example, your theme might have a “Continue reading” button for each post in a loop. That label is one of these.
The translation functions, __()
, _e()
etc. are exclusively for dealing with #2, and they are required if you want to allow these strings to be translated. WIthout them these strings will always be the language they were originally written in.
You can either bundle these translations yourself, or just provide a .pot file so that users can create translations themselves. If your theme properly implements localization, and is distributed via the WordPress.org Theme Repository, then users can use https://translate.wordpress.org to create a translation in their language. An overview of localization in WordPress is provided here.
When it comes to #1, content, these functions are not required. Users can set their site to whatever language they like, and enter content in whatever language they like. The only exception is right-to-left languages. To support those a theme needs to provide styles for right-to-left languages. There is a code article on that here.
So what is WPML for? WPML provides tools that allow a site to have content in multiple languages. This is for situations where a site might need to offer content in two or more languages, and allow users to switch between them. WPML is not required to translate template strings, and it’s not needed to enter content in any language the author chooses. It’s solely for sites that need content in multiple languages.
Some multi-language plugins, like WPML, provide built in tools for translating template strings. These features mean users don’t need to depend on the theme author providing a translation, or need to have knowledge of translation tools. However, for these features to work you need to use the translation functions.
To summarise:
- Proper use of the translation functions allows your theme’s hard-coded strings to be translated.
- You do not need to provide the actual translations yourself. There are other tools users can use to do the translations themselves.
- Using the translation functions does not give you the features of WPML without a plugin.
- Users do not need WPML unless they are serving the same content in multiple languages.
- Always read the documentation. WordPress’ documentation on localisation is here.