Last active
October 30, 2023 15:33
-
-
Save jstask82/fff0112c6ead289b4b16a01e1b7af46a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function translations() | |
{ | |
add_filter( | |
"get_term", | |
function ($term, $tax) { | |
if (is_admin()) { | |
return $term; | |
} | |
$fixes = [ | |
"fix" => [ | |
[ | |
"taxonomy" => "event-type", | |
"mappings" => [["reccuring", __("Wiederkehrend", NAME_SPACE)], ["single", __("Einzel", NAME_SPACE)]], | |
], | |
], | |
]; | |
foreach ($fixes["fix"] as $fix) { | |
$text = []; | |
if ($fix["taxonomy"] === $tax) { | |
foreach ($fix["mappings"] as $map) { | |
$text[$map[0]] = $map[1]; | |
} | |
return $text[$term->name]; | |
} | |
} | |
return $term; | |
}, | |
10, | |
2 | |
); | |
add_filter( | |
"gettext", | |
function ($translated, $untranslated, $domain) { | |
$fixes = [ | |
"fix" => [ | |
[ | |
"text_domain" => NAME_SPACE, | |
"mappings" => [["recurring", "Wiederkehrend"], ["single", "Einzel"]], | |
], | |
], | |
]; | |
foreach ($fixes["fix"] as $fix) { | |
$text = []; | |
if ($fix["text_domain"] === $domain) { | |
foreach ($fix["mappings"] as $map) { | |
$text[$map[0]] = $map[1]; | |
} | |
return str_ireplace(array_keys($text), $text, $translated); | |
} | |
} | |
return $translated; | |
}, | |
999, | |
3 | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment