Skip to content

Instantly share code, notes, and snippets.

@mayukojpn
Last active July 27, 2017 17:08
Show Gist options
  • Save mayukojpn/95d7cd2be1438001ffafe8e774e888b5 to your computer and use it in GitHub Desktop.
Save mayukojpn/95d7cd2be1438001ffafe8e774e888b5 to your computer and use it in GitHub Desktop.
WooCommerce 内の翻訳を置き換えるサンプル
<?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