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 building a WordPress site that is supposed to end up with a Danish backend. This works fine for core WordPress, but some plugin makes it really hard to make a complete translation.

A problem I just found has to do with the relationship field in the ACF plugin. I love the plugin, but there seems to be one bad call here from the developer's side. Or maybe I'm missing something. The problem is the post_type descriptions here:

Relationshipfield

So the problem is where it says "Production". That's a custom post type that I've set up with a Danish label "Forestilling" with CPT UI.

But when I look into the code behind this relationship field it seems to be pulling the post_type rather than the label:

// right aligned info
$title = '<span class="relationship-item-info">';

if( in_array('post_type', $field['result_elements']) )
{
    $title .= get_post_type();
}

// WPML
if( $options['lang'] )
{
    $title .= ' (' . $options['lang'] . ')';
}

$title .= '</span>';

I would assume that they took their precaution with the WPML section. But I'm not using WPML, and have no idea if this is needed just to change the translations.

All I would do is swap the get_post_type line with this:

$title .= get_post_type_object( get_post_type( $post ) );

But that means hacking the plugin, and this would be overwritten as soon as I update the plugin.

How could I go about fixing this?

share|improve this question

2 Answers 2

Simply change your Post Type to "Forestilling" instead of "Production".

I know it sucks having to use Danish words in code, but it seems necessary in this case.

The plugin is pulling the Post Type, and that's the correct thing to do, since you can change the label as much as you want, without this affecting the code/plugin, but the Post Type is static, used in the code, in the database, for calls and much more, and thus also used in the Relationship Field (correctly) as Post Type.

share|improve this answer

You should leave the post type name (and everything else that might need to be translated) in English.

Then, in WPML, you can translate its name (labels, and slugs).

If the main language of the site is Danish, you simply set this language as default language (not for WPML String Translation though, where I would keep English as default).

If the reason of using WPML is to just provide a Danish back-end, but the site is not supposed to be multilingual, the way to do so is by enabling a second language (e.g. English) and marking it as hidden.

But still, is always better to keep all strings in English (gettext, custom post types labels and slugs are strings).

share|improve this answer

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.