New WordPress Plugin: Translate Words

Last week I had a theme customer who wanted to translate some words on their website. The changes they wanted to make were small, and so I wanted a simple plugin to make the changes.

I knew that from a technical point of view it could be done easily. A filter on the gettext hook and a check for the string, so I could have fixed it easily. But what if the customer wanted to change something else in the future? I wanted it to be self service.

I had also had a need to do something similar myself. My sites are always in English, and themes and plugins are mostly in English, but sometimes I want to change the copy so it’s more appropriate or personal to me, so I started searching for a plugin.

I found quite a few translation plugins but most were too complex. They were for translating the entire site, or setting up a multi-language site, and that’s not what I wanted. I basically wanted a back-end for the filter I mentioned before.

The Translate Words Admin screen.

The Translate Words Admin screen.

The closest plugin I found was a plugin called WP Override Translations, but I felt it could be simpler still. So rather than use it and move on, I spent a day rewriting it as my own plugin.

Translate Words

*

I named my plugin Translate Words. It has a simple table that lets you enter the word/ phrase you want to change and what you want to change it to.

  1. It works on the front-end and the admin.
  2. It translates anything that goes through the gettext hook, including translations.
  3. It’s quick! The front-end code is about 20 lines long with one autoloaded database request.

Use Cases

The obvious use case is translations, but you can also use it to change text. For example changing a title from ‘Recent Stories’ to ‘Recent Articles’. This is the sort of thing that you would normally create a child theme for, or filter somehow. But now it can be done quickly and easily.

It took me a day of work but my goal with plugins is always to create something simple that will save me time in the future. I’ve wanted this for myself in the past, and now I can share it with my customers so that they can tweak the text content on my themes to their tastes. The fact it works with translated content means users can use the translation files, and still override the copy to fit their site.

Win win I think!

Credit

I should add a note about credit. As I mentioned, I forked a plugin called WP Override Translations, and through a conversation on Twitter I found out that plugin is itself a fork of Gettext override translations.

Both plugins could be used instead of mine. Obviously I think my version is better because of it’s simplicity but they do offer a couple of extra features that might be useful to you.

How was it for you? Let me know on BlueSky or Mastodon

(Please) Link to this page

Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.

Related Posts

01 Apr 2015

The State of WordPress Themes #wcldn

I recently spoke on a panel at WordCamp London 2015e. Lance – who used to be the Theme Team lead at WordPress.com – asked me if I wanted to speak on a panel with him at WordCamp London 2015. I’ve...
27 May 2013

WordPress: 10 Years Young, What Does The Future Hold?

WordPress is now 10 years old. I started using wordpress 9 years ago – which means I joined the WordPress community early on. The reason I chose WordPress is simply because of the fabled 5 minute install process – I...
13 Oct 2016

Lessons Learned from 20 Theme Releases on WordPress.com

In 2007 I partnered with Darren Hoyt to release Mimbo Pro, one of the earliest premium WordPress themes. In 2012 Mimbo Pro was published on wordpress.com. Last week – on October 5th 2016 to be precise – my 20th theme...
08 Aug 2013

The Death of WordPress Theme Frameworks

WordPress theme frameworks are on their way out. They’re dying a slow death. At least that’s what I think.Nathan Rice recently wrote an article with his thoughts about theme frameworks – in defense of them – however he clearly has...
04 Nov 2016

Automating WordPress Development with Gulp, Bash, and PHP

When I wrote about the things I had learned from releasing 20 WordPress themes, I mentioned that I had automated as much as I could. One of the things I automated was the build and deployment process for my themes...