Woocommerce에서 특정 텍스트 변경 또는 번역
온라인에서 해결책을 찾았는데 안 되는 것 같습니다.
며칠 전에 했던 아래 파일을 수정하라고 되어있는데 어찌된 영문인지 작동이 안 됩니다.
/wp-content/플러그인/wocommerce/templates/단품/관련
서버로 FTP하면 파일에 다음이 표시됩니다.
if ( $products->have_posts() ) : ?>
<div class="related products">
<h2><?php _e('You may also like', 'woocommerce' ); ?></h2>
그러나 웹 페이지에는 '좋아요'가 아닌 '관련 제품'이 표시됩니다.
어떤 이유에서인지 이것은 발생하지 않거나 어디선가 무시되고 있습니다.
무슨 생각 있어요?
아이 기능을 위해 이걸 찾았어요php: http://speakinginbytes.com/2013/10/gettext-filter-wordpress/
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
$translated_text = __( 'Check out these related products', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
여기서 잘 작동합니다. https://mo-sound.com/en/shop/ball-speaker-classic-white/
기본 템플릿을 재정의하는 가장 좋은 방법은 파일을 다음 이름의 폴더에 복사하는 것입니다./woocommerce/single-product
당신의 현재 테마 안에.해당 파일을 변경합니다.
일반적으로 다음과 같은 우커머스 템플릿 파일을 재정의합니다.
/wp-content/plugins/woocommerce/templates/<foldername>/<filename>
당신은 파일을 복사합니다.
/wp-content/<your-theme>/woocommerce/<foldername>/<filename>
여기 있습니다.user5217948
필요한 경우의 업데이트가 포함된 코드.Frithir
:
// CHANGE RELATED PRODUCTS TEXT
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related products' :
$translated_text = __( 'You may also like...', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
이 코드는 WooCommerce 3.3.1 및 WordPress 4.9.4에서 작동합니다(둘 다 2018년 2월경).
.
다른 언어로 우커머스/워드프레스를 사용하는 사람들을 위한 친절한 팁
언어에 표시되는 텍스트로 '관련 제품'을 바꿔야 합니다.저의 경우, 관련 제품은 "productos relacionados"로 번역됩니다.
함수에 포함할 코드.php 파일
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Productos relacionados' :
$translated_text = __( 'Completá el look', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
2020년 업데이트
제안된 검색 및 교체 방법 대신 보다 정확한 필터를 사용할 수 있습니다.
이 토막글을 기능에 추가합니다.당신의 자녀 테마에 있는 php 파일.
/*-------------- Change related products text -------------*/
add_filter( 'woocommerce_product_related_products_heading', 'single_related_text' );
function single_related_text(){
return __('These products might be if your interest as well!', 'woocommerce');
}
PHP 토막글입니다.하위 테마 기능의 하단에 PHP 토막글을 배치합니다.php 파일:wp-content/themes/mythemename/functions.php
add_filter( 'gettext', 'mythemename_translate_woocommerce_strings', 999, 3 );
function mythemename_translate_woocommerce_strings( $translated, $text, $domain ) {
$translated = str_ireplace( 'text EN', 'text translated PT_BR', $translated );
return $translated;
}
저는 방금 제 사이트 중 하나에서 아래 코드를 성공적으로 사용했습니다.그것은 기능에 배치되어야 합니다.당신의 아이 테마에 php.'사용자 정의 텍스트 여기'를 사용할 단어로 대체합니다.
add_filter( 'gettext', 'wtd_related_products_text', 20, 3 );
function wtd_related_products_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related products' :
$translated_text = __( 'Your Custom Text Here', 'woocommerce' );
break;
}
return $translated_text;
}
언급URL : https://stackoverflow.com/questions/27259838/change-or-translate-specific-texts-in-woocommerce
'code' 카테고리의 다른 글
PHP 5.5의 password_hash 및 password_verify 기능 사용 (0) | 2023.10.25 |
---|---|
jQuery 상위 양식 찾기 (0) | 2023.10.25 |
증분 피연산자로 l 값이 필요 (0) | 2023.10.20 |
Azure DevOps - PowerShell 스크립트에서 변수 설정 및 사용 (0) | 2023.10.20 |
도커 파일에 인수를 전달하는 방법? (0) | 2023.10.20 |