Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I working with a theme that supports langauge settings. I've changed the setting in WP-Config to:

define('WPLANG', 'es_ES');

The theme I'm using did not provide the es_ES.po or es_ES.mo files so I created my own es_ES.po and took the es_ES.mo from es.wordpress.org (after I downloaded the Spanish version).

The translation is working but its not picking up the entries I specify in es_ES.po, for example:

#. Text in function
#: daydream/comments.php:78
msgid "Be nice!"
msgstr "Escribe!"

This still displays in English on my site.

UPDATE Just to clear something up, I'm not actually editing the core language files, the theme has its own language folder, this is where I created my es_ES.mo and es_ES.po.

Any help would be appreciated.

Regards, Stephen

share|improve this question
2  
Does the theme load the language files? –  toscho Feb 14 '12 at 16:00

1 Answer 1

You shouldn't be editing the core translation files to translate a plug-in or theme. Here's a (not so brief) run-down of how translations of plug-ins and themes work....

When a theme or plug-in wants to allow some text to be translated it wraps it inside a function like

__('This text can be translated','my-theme-or-plugin');

Translation functions

First of all, only text inside such functions will be able to be translated, as its these bits of text that WordPress recognizes can be translated. So first of all you must check that something like the following is present in the theme code:

__('Be nice!','my-theme-or-plugin');

Translation domains

Second of all, notice the my-theme-or-plugin. This is the theme's (or plug-in's) domain. It must be registered somewhere, to some location (inside the theme's folder). This is where WordPress looks to translate the string. If it is blank, it will use the core translation files (e.g. es_ES.mo) that are (when added) inside the language directory of the wp-contents directory. Themes should have their own domain and not rely on the core translation files (at least for strings that don't appear in the those files).

What this means is that if you translate a plug-in or theme you need to know their domain (e.g. my-theme-or-plugin) and you save your po/mo files as:

my-theme-or-plugin-{language extension}.mo/.po

For example: my-theme-or-plugin-es_ES.mo and my-theme-or-plugin-es_ES.po. These must be placed in the theme's / plug-ins registered area.

In short to translate a theme / plug-in you need to know:

  1. It's domain (see Codex)
  2. Where to put the po/mo files

You should not need to edit the 'core' language files: e.g. es_ES.po/es_ES.mo

Usually plug-ins and themes will provide a translation template file (sometimes POT), this is a list of strings the plug-in/theme allows to be translated. You can use this to create your my-theme-or-plugin-es_ES.mo/.po files and save it in the appropriate place.

You will have to contact the theme/plug-in author directly for the above information.

share|improve this answer
    
Thanks Stephen, I'm not actually editing the core translation files. The theme itself has a language folder. –  Stephen Feb 14 '12 at 16:48
    
Ah ok, well there may be a my-theme-or-plugin.po or my-theme-or-plugin.pot file in there. You should name your file appropriately and put it in the language folder. –  Stephen Harris Feb 14 '12 at 16:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.