Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Maja B.
Maja B.
12,984 Points

Is this the way Poedit should work ... or am I missing something?

Hi, I'm using WordPress Pho theme and I've customised it by making Pho-child theme. My side is bilingual (English and Slovene).

In the folder pho/languages there is a file pho.pot. I've created sl_SL.po file out of it and translated a few lines to see if it is working. And it does. I am able to translate a WP theme.

But what about the text that I myself write directly in the code? For example, in pho-child/single-book.php file (one of my custom post types, created with Custom Post Type UI plugin) I need to write "Published by:"

Here is how I write it in the pho-child/single-book.php file:

<p><?php _e( 'Published by', 'pho' ); ?></p>

I thought that this would be enough to make WordPress grab that line and place it into pho-pot file from where I will be able to (by creating a sl_SL.po file once again and deleting the old sl_SL.po) translate it in Slovene.

But it does not. "Published by" does not appear in pho.pot file and therefore I do not know how to translate it.

So how do you add new entries into Poedit? I've searched the web and found no clear explanation ...

1 Answer

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

I don't think it adds your line automatically, but you can add it to the file and it should work.

Maja B.
Maja B.
12,984 Points

Okay, thanks, Zac. But how? There is no "Add new entry" in the Poedit programme.

Besides, here someone is asking the same question as I do: http://poedit.net/trac/ticket/3.html

Question: I cannot add or remove items manually (Am I missing something ?)

And the answer led me to think that new entries are added by WordPress going through all the files and finding those lines of code that are translatable and than adding them automatically to Poedit.

Answer: Yes, the very way gettext works ;-) Gettext message catalog contains strings that are present in source files and *only these strings. The only way to update gettext catalog is to scan the sources for strings. poEdit merely follows this philosophy (after all, it is a frontend to gettext!).*