Skip to content

Instantly share code, notes, and snippets.

@shirokoweb
Created February 16, 2019 09:18
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 shirokoweb/357252ecb42de501c42918941c759423 to your computer and use it in GitHub Desktop.
Save shirokoweb/357252ecb42de501c42918941c759423 to your computer and use it in GitHub Desktop.
Translate a String in WooCommerce
add_filter( 'gettext', 'webplus_translate_woocommerce_strings', 999 );
function webplus_translate_woocommerce_strings( $translated ) {
// Store all string in an array
$translatedStrings = array(
'Sale!' => 'ON OFFER',
'Product Description' => 'Product Specifications',
);
$translated = str_ireplace( array_keys($translatedStrings), $translatedStrings, $translated );
return $translated;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment