Last active
July 17, 2022 14:34
-
-
Save stuartduff/3144286 to your computer and use it in GitHub Desktop.
WordPress Translate Text testing Snippet - this snippet when added to a themes functions.php file will let you test if the Localization of a word or text string is taking effect and changing within a theme or plugin without using the translation .MO and .PO files.
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 translate_text( $translated ) { | |
// The first parameter is the original text, the second parameter is the changed text. | |
$translated = str_ireplace( 'Choose and option', 'Select', $translated ); | |
// Returns the translated text | |
return $translated; | |
} | |
add_filter( 'gettext', 'translate_text' ); | |
add_filter( 'ngettext', 'translate_text' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @stuartduff ! This snippet when added with Code Snippet plugin in wordpress is working fine too. Then I didn´t to edit funcions.php.