Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- - 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00
- - - - - - -

Supporter timezone: America/Lima (GMT-05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Andreas W. 1 year, 1 month ago.

Assisted by: Andreas W..

Author Posts
March 22, 2024 at 4:39 pm #15441827

margarita

Tell us what you are trying to do?
Hi! I'm trying to translate some Astra theme strings. I have a woocommerce and I need to translate the shopping cart icon aria-label "View Shopping Cart, x items" and the screen-reader-class "Main Menu".

Is there any documentation that you are following?
https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/

The View Shopping Cart... doesn't appear, no matter what I try. "Main menu" is already translate on wpml string translation, but still in english in front-end.

Is there a similar example that we can see?
No, sorry

What is the link to your site?
hidden link

I appreciate your help
Margot

Captura de pantalla 2024-03-22 a las 17.38.19.png
Captura de pantalla 2024-03-22 a las 17.35.02.png
Captura de pantalla 2024-03-22 a las 17.34.21.png
March 23, 2024 at 1:57 pm #15443196

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

The strings that you already translated very likely are not the actual strings that you are trying to translate.

The issue with this approach might be that those those HTML attributes are not coded in a way inside Astra, that would allow the registration of the strings for translations.

If I check for this string in Astra, it looks like this:

\astra\inc\compatibility\woocommerce\class-astra-woocommerce.php on line 3355:

$aria_label = $cart_count > 0 ? "View Shopping Cart, {$cart_count} items" : 'View Shopping Cart, empty';

The "Main Menu" string is located at \astra\inc\builder\controllers\class-astra-builder-ui-controller.php on line 222:

<div class="ast-button-wrap">
				<button type="button" class="menu-toggle main-header-menu-toggle ast-mobile-menu-trigger-<?php echo esc_attr( $toggle_btn_style ); ?>" <?php echo apply_filters( 'astra_nav_toggle_data_attrs', '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> <?php echo esc_attr( $aria_controls ); ?> aria-expanded="false">
					<span class="screen-reader-text">Main Menu</span>
					<span class="mobile-menu-toggle-icon">

As you can see in the above example, the span element with the class "screen-reader-text" is using hard-coded HTML and this is not translatable.

I also find another example for the string "Main Menu" which is translatable and registered and translated on your site, but this seems not to be the string that you are looking for.

It is located inside astra\inc\template-parts.php line 173:

	function astra_masthead_toggle_buttons_primary() {

		$disable_primary_navigation = astra_get_option( 'disable-primary-nav' );
		$custom_header_section      = astra_get_option( 'header-main-rt-section' );
		$display_outside_menu       = astra_get_option( 'header-display-outside-menu' );

		if ( ! $disable_primary_navigation || ( 'none' != $custom_header_section && ! $display_outside_menu ) ) {
			$menu_title          = trim( apply_filters( 'astra_main_menu_toggle_label', astra_get_option( 'header-main-menu-label' ) ) );
			$menu_label_class    = '';
			$screen_reader_title = __( 'Main Menu', 'astra' );
			if ( '' !== $menu_title ) {
				$menu_label_class    = 'ast-menu-label';
				$screen_reader_title = $menu_title;
			}

			$menu_label_class = apply_filters( 'astra_main_menu_toggle_classes', $menu_label_class );
			?>

Now, this last example is coded correctly, but it looks to me as if this is not the string that you are looking for. You seem to look for the string from the prior example, which is hard-coded HTML and not translatable in the way it is coded.

This is a developer topic and is explained here:
https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

This means, that to make those strings translatable, the Astra Team would need to adapt their code.

I suggest you first reach out to Astra Support about this matter, please feel free to share my findings and ask if they would consider looking into this, running some tests, and making those HTML attributes translatable.

Take note, that this is not WPML specific - you would run into the same issue with any translation plugin.

If any further assistance from our side will be needed, please let me know.

Best regards
Andreas

The topic ‘[Closed] Accessibility problems: aria-label and screen-reader’ is closed to new replies.