Until Yesterday, I’ve never had a reason to modify WordPress language files. But yesterday, I installed the Yoast Local SEO plugin on a site and noticed that the company field called Second Phone showed up on the page as Secondary Phone. The client wanted it to say Toll Free. That’s when I began a two hour search trying to figure out how I could modify a language file without hacking the plugin.
First, let me explain what the language files do. WordPress uses a language framework that allows WordPress developers to add messages to their program. The user will see these messages in the WordPress administration screens, in error messages, and on the pages of the website. By using language files, WordPress makes it possible to customize these messages or translate them to a different language without editing the program files of WordPress or the Plugin.
For example, when you log into WordPress, there is language on the screen. By modifying the WordPress core language file, you can change any of the text on this screen except the website Title.
In my case, the Yoast Local SEO plugin used language, Secondary Phone, that I needed to change.
If you want to change WordPress or Plugin messages, the following are your choices:
- Install a plugin that allows you to change language strings.
- Use POEDIT to edit the language files.
Note: Whenever possible, I prefer to change WordPress or add functions to WordPress manually rather than by using a plugin. First, by manually adding code, it helps me learn how WordPress works. Second, unless it’s absolutely necessary, I don’t want to depend on a plugin and the baggage that brings. For example, the Say What? plugin adds tables to your database. There’s nothing wrong with this, but, in the case of changing plugin messages, I prefer the manual way because it is much more streamlined : the only thing you add to WordPress is a modified language file.
Change WordPress Language Using a Plugin
This is the easiest method. Install the plugin, enter the original message and the replacement message and save.
- Install the Say What? plugin. Click here for instructions on installing WordPress plugins.
This plugin allows you to modify individual messages. - Find the Text Domain of the Plugin whose Message you are Changing.
Note: If you’re changing a WordPress core message, you don’t have to enter a text domain.
To find the text domain for the plugin, look at the plugin’s language file name.
For example, for Yoast Local SEO plugin,
/wp-content/plugins/wpseo-local/languages/yoast-local-seo.pot
The text domain for Yoast local plugin is yoast-local-seo - Create a New Text Change using the Say What? Plugin.
- Go to Tools > Text Changes > Add New
- Enter the original string. It must be the exact same spelling and case as the screen message.
- Enter the Text domain of the plugin.
- Enter the Replacement String
- Click Add to save the message change.
Change WordPress Language Manually
To change WordPress language manually requires that you install POEDIT and upload language files to /wp-content. If you don’t have the ability to upload files or you are not comfortable doing it, use the plugin method above to change WordPress language.
Note: In the following tutorial, I will use the Yoast Local SEO plugin as an example. Your plugin language modification should be the same except for the paths and file names.
- Download and install POEDIT.
- Find the Text Domain of the Plugin whose Message you are changing.
Note: If you’re changing a WordPress core message, you don’t have to enter a text domain.
To find the text domain for the plugin, look at the plugin’s language file name.
For example, for Yoast Local SEO plugin,
/wp-content/plugins/wpseo-local/languages/yoast-local-seo.pot
The text domain for Yoast local plugin is yoast-local-seo - Create a languages folder in wp-content
For example /wp-content/languages - Create a plugins folder in /wp-content/languages
For example if you are changing WordPress core messages, that language file goes in
/wp-content/languages - From the POEDIT menu, select to File > New
- Select Language of Translation > English (United States) and click OK.
- Select Update from POT.
This will import all the language strings from the Yoast Local SEO plugin. - Save the file in /wp-content/languages/plugins and use the text domain of the plugin as the prefix.
For example, yoast-local-seo-en_US.po - Once you save the file, POEDIT prompts you to open the .pot file.
For example, /wp-content/languages/plugins/yoast-local-seo.pot
POEDIT imports all the message from the .pot file
- From the POEDIT menu, select Edit > Find and enter the message you want to change.
For example, Secondary Phone.
- In the Translation field, enter the new message.
For example, Toll Free. - From the POEDIT menu, select File > Compile to MO
- Save the .mo file in
/wp-content/languages/yoast-local-seo-en_US.mo - Reload the website page, where the message appears, to verify your message change.
Resources
The following is a list of resources for translating or modifying language files.
- Translating Your Theme – An EXCELLENT article explaining how to create a language file for your theme. Even though this article is specific to themes, it will explain all the terminology and explain how to use POEDIT to create your language files.
- Customizing Labels, Messages, and URLs
- Create a .pot or .po File using Poedit
Leave a Reply