Last active
July 27, 2017 17:08
-
-
Save mayukojpn/95d7cd2be1438001ffafe8e774e888b5 to your computer and use it in GitHub Desktop.
WooCommerce 内の翻訳を置き換えるサンプル
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
<?php | |
/* | |
* Plugin Name: WB Tokyo Pig Latin | |
* Text Domain: piglatin_woo | |
*/ | |
add_filter( 'gettext', 'piglatin_woo', 10, 3 ); | |
function piglatin_woo ( $translation, $text, $domain = '' ) { | |
if ( 'ja' !== get_locale() ) { | |
return $translation; | |
} | |
if ( 'woocommerce' !== $domain ) { | |
return $translation; | |
} | |
switch ( $text ) { | |
case 'Description': | |
$translation = 'ツアー内容'; | |
break; | |
default: | |
$translation = preg_replace( | |
'/^カート/', | |
'${1}お買い物かご$3', | |
$translation | |
); | |
} | |
return $translation; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment