All Collections
Create by Mediavine
Advanced
How To Provide Translations For Time Labels
How To Provide Translations For Time Labels
Sam Ellis avatar
Written by Sam Ellis
Updated over a week ago

In Create, time values correspond to the values that search engines look for in JSON-LD output. The values that need to be included are prep time, active time, additional time, and total time.
​
However, time labels are dynamic, which means you can edit them on a card-by-card basis. We built this feature because some cards call for different labels – if you're making popsicles, for instance, you probably want to display "Freeze Time" instead of "Cook Time" to your readers, since most people don't like their popsicles steaming hot.

This can create issues for translating the plugin. As opposed to the hard-coded labels in templates, such as "Ingredients," which will always be the same and therefore work with WordPress' translation capabilities, dynamic values like time labels are going to output whatever is in your database without being translated.
​
The good news is that if you provide a translation for these labels, any cards created after that point will use them by default. However, this won't apply to previously-created cards, which already have their data saved.

You can add the following snippet to your theme's functions.php file

add_filter('mv_create_card_render', function($html) {
$html = str_replace("Cook Time", '<YOUR TRANSLATION>', $html);
$html = str_replace("Additional Time", '<YOUR TRANSLATION>', $html);
$html = str_replace("Prep Time", '<YOUR TRANSLATION>', $html);

return $html;
});

This filter will replace the default labels in your card output with whatever you set the translation to be. If you're running into issues with other strings not translating properly, such as time units like "minutes," you can add additional lines to replace those with the correct translation.
​
Modifying your functions.php file is inherently risky, so take extra caution while doing this to prevent typos. If you have any questions, please contact create@mediavine.com.

Did this answer your question?