Have you ever wanted to change some text that reads “Continue reading” or “Post written by” in your WordPress theme to something a little different?
That’s pretty easy to do if you just open the appropriate PHP file and edit it. But what happens when the theme is updated with some cool, new feature or for the next version of WordPress? Well, you have to change that text all over again.
Wouldn’t it be much easier to simply change the text once and not be hassled by theme upgrades?
Something all WordPress theme authors and users could use a little more of is protection from this. It’ll take a little work from both ends though.
Ian Stewart has already detailed some ways to to protect themes against upgrades. I wanted to take his idea little step farther by showing another simple way to help in this regard.
We’ll basically be using the same techniques as theme and plugin translators use. If you’ve ever translated any of my themes, you deserve some major respect. The Options theme alone has 220 different text strings!
If you look under the hood of some of my themes, you might find some weird PHP that looks like this:
<?php _e('About the Author','options'); ?>
Your average theme might look something like this:
About the Author
The PHP from my theme allows for an easy way to change text strings without ever touching that line of code.
Tools you’ll need
First, you need a theme that is ready for localization. I haven’t seen many around, but both my Options and Structure themes are ready for translation.
You need to grab a copy of a neat little tool called Poedit. It’s what we’ll be working with.
Then, you need to read the best article there is around on localization from Weblog Tools Collection. I won’t bother going into the details of this process since the WLTC post is in depth enough.
Once you’ve done all of the above, you’re set.
Getting your new text strings to work
Let’s suppose you’ve played around with this Poedit thing a bit and finally decided to change some words around on your site. For this example, I’ll be using my Options theme.
Open “en_EN.po” from your Options theme folder in Poedit. You’ll be brought to a screen with a lot of text strings. In the bottom left, after clicking on a text string, you can alter it. After you change a few, your screen will look a little like this:

You don’t have to change every string. Just change the ones you want to be different.
Save this file as “wacky.po” for now. This and a file named “wacky.mo” should be saved in your Options theme folder. After this, go to the root of your WordPress folder. Open the file named “wp-config.php” in a text editor.
Find this bit of code:
define ('WPLANG', '');
Change it to this:
define ('WPLANG', 'wacky');
Save everything. Refresh your page. Your new text strings should be there.
Fun with the Options theme
I figured I’d give this a good go myself and tried to have a little fun with it. Here’s what I’ve come up with. Take a look at the two tabs sections and compare.

Notice the difference between the two sections? I never touched a line of code to get this effect. If you want to see my own personalization of text strings in the Options theme, just download this file:
Okay, the language isn’t too wacky. Just drop wacky.po and wacky.mo in your theme folder. Then, remember to change the settings in wp-config.php.
Encouraging others to follow
I know this isn’t the coolest thing since the birth of Alan Turing, but it will help, especially if you’re even a little bit geeky.
If you’re a theme author, you should probably be making your themes ready for translation anyway. If your theme doesn’t support localization, encourage your theme author to update the theme.
Anyway, have fun with it.
Here are some good resources on localization (especially for theme and plugin authors):
You’re so right Justin—there’s not enough “localizable” themes available.
This is a great tip that I hope more theme authors will pick up on.
As a programmer a few years back I used this extensively in the software I wrote so that it could be localized for the French and English in bi-lingual Canada.
There’s no reason localization can’t become the norm in WordPress themes too.
There’s a part of me ready to declare this a very good idea and another part of me that is begging to know how often such a thing would be used.
It seems to me that this system is as (or more) complicated than changing the theme itself. It also seems that few people are going to be aware of–or terribly interested in–changing most of these variables.
That said, for users who blog in a language other than the one being used by a–regularly updating–theme author, this could be a GREAT thing.
I guess the point I’m making is that this strikes me as a rather interesting idea, but not one I’m excited to immediately go and implement.
Richard H
Localizing themes can open up a theme author to an entirely new audience. I believe since I started doing this, I’ve gotten a lot more international users willing to use the themes.
David
For protection against theme upgrades — no, it won’t be used much. It was just a neat idea I thought about doing and figured I’d post it as kind of a twist on how localization works.
It’s actually not hard to implement. If the English .po file is available, all a user has to do is load the file in Poedit and translate whatever strings they want. It could literally take less than 5 minutes.
Edit : I do want to add that it would be more complicated for first-time users of Poedit though.
Truely man WP plugin and theme authors ignore the idea of localization which affects the end-users.
By the way I wonder why WordPress accepts non-standard localization filenames like
mycrazylanguage.poasdefine ('WPLANG', 'mycrazylanguage');instead of accepting only gettext standards such asen_US.po/en_US.mooren_EN.po/en_EN.modefined in WP asdefine ('WPLANG', 'en_EN');Nice tip, JT.
J Mehmett
I’m not sure why WordPress accepts non-standard localization file names. But, here’s a question. What if WP only accepted standard names and someone wanted to create a site purely based on an Elvish language (Lord of the Rings)?
Hey, it could happen.
I do agree though that plugin and theme authors could really help out the community by adding a few extra lines of code to their themes. The average theme wouldn’t have too many strings to change anyway.
Of course that’s why WordPress is independent.
WordPress was designed to help all, and to produce better open source world. Localization is part of better WordPress.
Edit : I do want to add that it would be more complicated for first-time users of Poedit though.
This is what i am going to back off! I have always wonder how to not destroy my already customized theme, but now it seems a bit more work for a noob like me
[...] Tadlock talks about theme localization, and reveals how to protect your text strings from theme upgrades. Have you ever wanted to change some text that reads “Continue reading” or “Post written [...]
[...] Protecting text strings from theme upgrades – This post by Justin Tadlock goes over how to make your themes translatable. I’ll admit, this is something I do not do with the themes on Theme Lab, but I may start after reading this. [...]
This is a pretty cool idea. But the perfectionist in me makes me want to take out the middle man “poedit” and create an interface via PHP for this. hmm…
J Mehmett
Here’s a little something I just found out. The Default WordPress theme isn’t even localized! I haven’t looked at that for a while, but I just happened to open it the other day and noticed it.
gofree
The good thing is that you can’t possibly mess up your theme using this method. If something goes wrong, you only have to worry about one file. In the long run, it might be worth it to learn PoEdit.
Ptah Dunbar
Now, I’m interested. That could be a neat way to do it.
Maybe if you could set up a theme options page with all the text strings, it could work. What would be even neater would be if you could have the options page auto-generate the .mo and .po files. That way, you wouldn’t have to hack up your theme files getting theme options for every string.
An interesting thing here, is that it opens doors for guys like me, that writes about life in the kitchen and my “well-known” recipes, with a twist of daily stories.
I have tried out every single multilanguage plugin there is, but i cant seem to get any of them to work properly! YET.
With a localized theme it might just be posible and maybe i dont have to post recipes in english elsewhere, but on the “english” site of my blog!-