This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Marcos Vinicios Barreto 2 months, 3 weeks ago.

Assigned support staff: Marcos Vinicios Barreto.

Author Posts
July 25, 2019 at 2:10 pm

aykhanA

I am trying to: Localize breadcrumbs custom function for Tribe Events Calendar

Link to a page where the issue can be seen: dev.pressklub.az/events

I tried to follow the __gettext instructions via WordPress Codex & WPML forum topics but it keeps resulting in a fatal error that breaks my site, would appreciate any help or insight on how to get the strings in the function below localized.

My functions.php breadcrumbs code I'm trying to localize:

// Breadcrumb Logic
function tribe_breadcrumbs() {
global $post;

$separator = " » ";

echo '<div class="tribe-breadcrumbs">';
echo '<a href="' . get_option('home') . '">' . bloginfo( 'name' ) . '</a>';

if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
echo $separator;
echo 'The Events Calendar';
} elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
global $wp_query;

$term_slug = $wp_query->query_vars['tribe_events_cat'];
$term = get_term_by('slug', $term_slug, 'tribe_events_cat');
get_term( $term_id, 'tribe_events_cat' );
$name = $term->name;
echo $separator;
echo '<a href="'.tribe_get_events_link().'">Events</a>';
echo $separator;
echo $name;
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List
echo $separator;
echo 'Events List';
} elseif( tribe_is_event() && is_single() ) { // Single Events
echo $separator;
echo '<a href="'.tribe_get_events_link().'">Events</a>';
echo $separator;
the_title();
} elseif( tribe_is_day() ) { // Single Event Days
global $wp_query;

echo $separator;
echo '<a href="'.tribe_get_events_link().'">Events</a>';
echo $separator;
echo 'Events on: ' . date('F j, Y', strtotime( $wp_query->query_vars['eventDate']) );
} elseif( tribe_is_venue() ) { // Single Venues
echo $separator;
echo '<a href="'.tribe_get_events_link().'">Events</a>';
echo $separator;
the_title();
} elseif ( is_category() || is_single() ) {
echo $separator;
the_category(' • ');

if ( is_single() ) {
echo ' '.$separator.' ';
the_title();
}
} elseif ( is_page() ) {
if( is_child(get_the_ID()) ) {
echo $separator;
echo '<a href="' . get_permalink( $post->post_parent ) . '">' . get_the_title( $post->post_parent ) . '</a>';
echo $separator;
echo the_title();
} else {
echo $separator;
echo the_title();
}
} elseif (is_search()) {
echo $separator.'Search Results for... ';
echo '"';
echo the_search_query();
echo '
"';
}
echo '</div>';
}

July 25, 2019 at 3:21 pm #4284639

Marcos Vinicios Barreto
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Bahia (GMT-03:00)

Hello,

Thank you for contacting WPML Support. Although it is related to a custom code work something not really related to our forum support, I am still able and happy to help you with some tips on how to achieve it. Please, try the following:

1 - For the line 'echo 'The Events Calendar' you can try the code below:

esc_html__('The Events Calendar', 'text-domain');

Where the 'text-domain' value below is the text domain you will use to translate your content using WPML String Translation.

2 - For the line 'echo '<a href="'.tribe_get_events_link().'">Events</a>' you can try the code below:

<a href='"' . tribe_get_events_link() . '">'.esc_html('Events', 'text-domain').'</a>';

3 - For the line 'echo 'Events on: ' . date('F j, Y', strtotime( $wp_query ->query_vars['eventDate']) );

echo esc_html( 'Events on: ', 'text-domain' ) . date('F j, Y', strtotime( $wp_query ->query_vars['eventDate']) );

4 - For the line 'echo $separator.'Search Results for... ' you can try the code below:

echo $separator . esc_html( 'Search Results for... ', 'text-domain' );

Note, however the code above needs to be adjusted to your needs, also double check for any missing semicolon, single quote, double quotes etc, they are in most cases the cause of your fatal php errors (syntax error).

See: hidden link

I still recommend you to get in touch with one of our WPML contractors, in case you need an advanced code customization at: https://wpml.org/contractors/

Hope it helps, have a nice day.