Как перевести конструктор главной
Перевод элементов конструктора главной необходимо задавать вручную. Для этого нужно добавить такой код в плагин https://support.wpshop.ru/docs/general/profunctions/
function bono_translate_items( $text ) {
$items = [];
switch ( substr( get_locale(), 0, 2 ) ) {
case 'ru':
$items = [
'Hi there!' => 'Приветики!',
// add more translations here
];
break;
// add more locales here
default:
break;
}
if ( array_key_exists( $text, $items ) ) {
return $items[ $text ];
}
return $text;
}
add_filter( 'bono_homepage_constructor:categories_section_header_text', 'bono_translate_items' );
add_filter( 'bono_homepage_constructor:html_section_header_text', 'bono_translate_items' );
add_filter( 'bono_homepage_constructor:posts_section_header_text', 'bono_translate_items' );
add_filter( 'bono_homepage_constructor:products_section_header_text', 'bono_translate_items' );
add_filter( 'bono_category_slide_item_title', 'bono_translate_items' );
add_filter( 'bono_category_slide_item_description', 'bono_translate_items' );
add_filter( 'bono_category_slide_item_button_text', 'bono_translate_items' );
add_filter( 'bono_homepage_constructor:slide_title', 'bono_translate_items' );
add_filter( 'bono_homepage_constructor:slide_button_text', 'bono_translate_items' );
add_filter( 'bono_homepage_constructor:slide_excerpt', 'bono_translate_items' );
Т.е. мы, например, по умолчанию задаем заголовки, текст кнопки и т.д. в конструкторе на английском. А затем для нужного языка добавляем переводы, которые будут с помощью данной функции подтягиваться в зависимости от текущей локали.
Вам помог ответ?