How to edit theme strings with translations

The vast majority of the text on your site comes from your own content. However there’s a small amount that comes with the theme and that in very few instances you’d wish to change to something else.

The first though would be to dive right into the theme files and search for that text to edit it right there, right? That usually works, but just not always (not all theme files are simply customizable using a child theme, not all functions can be unhooked, and so on).

Luckily, WordPress provides for a way to do this more easily. With the aid of translations, we can simply tell WordPress to display a particular string in the place of a built-in one (as long as the theme supports translations and all its strings are translateable – all our themes are). “But translating the theme to a different language is not what I need”, some will say. Don’t worry, you don’t have to: you can “translate” the theme from English to English, too.

As an example I’ll be using Nirvana and we’ll say we want to edit the “Bookmark” label (displayed at the end of single posts), changing it to “Add this to favorites”.

editing-strings-with-translations-0

  1. We’ll start by installing a translation editor plugin – my plugin of choice is Loco Translate which we can install by navigating to Plugins > Add New and typing its name in the filter box at the top.

editing-strings-with-translations-1

Click Install now and then Activate.

2. Navigate to Loco Translate > Themes and select the desired theme from the list. Click the New language button below the theme name

editing-strings-with-translations-2

Optional: At the next step you may get a Template missing warning message (in case the author did not include a POT file with the theme). We can click Create template to tell Loco translate to generate the translations from source (may take slightly longer) and then we can resume the language creation step.

3. Next we chose the language we want to edit – in the case of this tutorial this will be the English (United States) because we need to edit strings in the theme that while not actually switching to a different language.
However this is also possible for any other language.

editing-strings-with-translations-3

For the file location do NOT chose the first option – this would place the new translation in the theme folder which will be lost at the next theme update. We’ll be using System. Click on Start translating.

4. We finally arrive at the translation editing screen. Here is where we browse through or search all the theme strings and can insert translations for them.

Search for ‘bookmark’ (the string we initially wanted to change) – the plugin will dynamically filter and show results that match.

Select the string by clicking on it and enter the desired “translation” (or in our case replacement string) in the bottom box:

editing-strings-with-translations-4

Repeat this for all strings that we want to edit, then finally click Save.

That’s it! We can now return to the frontend to find our new text in place:

editing-strings-with-translations-5

This procedure will work with all our themes to edit any of their texts without actually editing files.

More Tutorials This article is part of our WordPress general and theme specific tutorials series. For more useful information check out our tutorials section.

6 Comments

  1. In the end, a text file or database entry is being changed, correct? Is there a way I can do this without a plugin? I try my best to not use plugins unless absolutely necessary for security reasons. And all I need to do is change the text in the search box. I hate to have to load a plugin for that.

    1. You can install and use the plugin just to make the changes, then remove the plugin once you’re done.
      Alternatively, you can use Poedit to edit translations offsite (locally on your computer) then upload them to the site, but Poedit doesn’t yet support multiple text domains (like we use in our themes).

  2. My authors name, links and a number of text items are acting like dynamic text. You can’t see them until the mouse hovers over them. My web hosting offers no help as I’m not using their themes any longer, but Cryout Creations. I plan in the next week to purchase priority since I’ve been ousted from the help desk where I host and reside. It’s a sad but true story. Can you assist me or direct me to a answer?

    Thanks,

    Gary Leese

    p.s. just in case your like really nice and have the time, even though I am not a priority member. My web site example is http://www.earthgymgear.com/nicole-decker-wears-lululemon-aurora-circuit-breaker-skirt/ and if you hover in the middle of the blog you’ll see my #4 Paragraph hidden text and you’ll notice the author (by) which is me is also hidden until you hover. Thanks

    1. Those texts are always there, but the combination of colours makes them invisible until you hover. Try out something other than white as the theme’s main accent colour.
      Note that are other non-working colour combinations on your site as well (like widgets with black text on the black background).

  3. Hey Zed,
    Really Useful info and I had a same problem on my site. After read your tutorial I changed my themes strings using the above translations method. You mentioned Loco translator is working well.

    Thanks

This article is closed to new comments.