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'm trying to localize the singular name of a custom post type.

...
'singular_name' => __('key', 'plugindomain')
...

I created a .po and compiled it as .mo. I also loaded the translation using load_plugin_textdomain using the init action.

// $directory plugin directory relative to plugins dir
load_plugin_textdomain('plugindomain', false, $directory);

The string are localized correctly in the backend sidebar. However, the strings are not translated in the frontend with:

// $post_type returned from get_post_type_object
echo $post_type->labels->singular_name;

Am I doing something wrong?

Edit

Apparently the problem is related to Polylang. Strings are loaded before the multilanguage plugin mentioned sets the current language during the execution. Is there a way to trigger the registration of post types after the language changes made by Polylang have had their effect?

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.