Skip to content

Instantly share code, notes, and snippets.

@wpt00ls
Last active February 21, 2023 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpt00ls/e87900e241455bf829c91d1f3c12ade8 to your computer and use it in GitHub Desktop.
Save wpt00ls/e87900e241455bf829c91d1f3c12ade8 to your computer and use it in GitHub Desktop.
Internationalization filter for food recipe plugin
<?php
/**
* Italian Translation string for food recipes plugin.
*
* Add this code in a child theme
*/
add_filter(
'gettext',
function (
$translated_text,
$text,
$domain
) {
if ($domain == 'food-recipes') {
switch ($translated_text) {
case 'Food Recipes':
$translated_text = 'Ricette Alimentari';
break;
case 'Recipe By':
$translated_text = 'Ricetta Di';
break;
case 'yr': //year
$translated_text = 'anno';
break;
case 'yrs': //years
$translated_text = 'anni';
break;
case 'mo': //month
$translated_text = 'mese';
break;
case 'mos': //months
$translated_text = 'mesi';
break;
case 'day':
$translated_text = 'girono';
break;
case 'days':
$translated_text = 'giorni';
break;
case 'hr': //hour
$translated_text = 'ora';
break;
case 'hrs': //hours
$translated_text = 'ore';
break;
case 'min': //minute
$translated_text = 'minuta';
break;
case 'mins': //minutes
$translated_text = 'minuti';
break;
case 'sec': //second
$translated_text = 'secondo';
break;
case 'secs': //seconds
$translated_text = 'secondi';
break;
case 'of': // "of" - used in ingredients e.g 1 bunch of parsley
$translated_text = 'di';
break;
default:
break;
}
}
return $translated_text;
},
99,
3
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment