Singular name Plugin localization

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?

0

Leave a Comment