Home Forums Basel support forum Change the Translation of SALE button

Change the Translation of SALE button

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #19488

    info@jullo.nl
    Participant

    Hi Team,

    You have a great theme i really love, but this it is the first time i use it and the amount of options is overwhelming 🙂 which is good but i do need your guidence.

    I would like to change the content of the sale button (banner) the round one that appears on the products in the right upper corner when they are on sale.

    Basically because the automatic translation changed it to the dutch equivalent of sale which is “Aanbieding” and that doesnt fit the container. So i would like to change the translation back to SALE.

    #19489

    Artem Temos
    Keymaster

    Hello,

    We are glad to know that you considered using Basel for your web-site. I hope you will be happy with it.

    Here is a video that demonstrates how to translate or change strings with Loco Translate plugin https://www.youtube.com/watch?v=tAFq1yTfWfU

    Kind Regards
    Xtemos

    #19490

    info@jullo.nl
    Participant

    Thx for the fast reply,

    I donnt want to use any plugin for translation. I would like to know the location of the po file of the specifc item.

    Like i said, woocommerce and the theme translated automatically, it adjusted to the current wordpress language. Ni i only need to change the specific content.

    #19491

    Eric Watson
    Participant

    Hello,

    Try to add the following code snippet to the functions.php file in the child theme and change your text.

    function basel_product_label() {
    	global $product;
    
    	$output = array();
    
    	if ( $product->is_on_sale() ) {
    
    		$percentage = '';
    
    		if ( $product->get_type() == 'variable' ) {
    
    			$available_variations = $product->get_variation_prices();
    			$max_percentage = 0;
    
    			foreach( $available_variations['regular_price'] as $key => $regular_price ) {
    				$sale_price = $available_variations['sale_price'][$key];
    
    				if ( $sale_price < $regular_price ) {
    					$percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    
    					if ( $percentage > $max_percentage ) {
    						$max_percentage = $percentage;
    					}
    				}
    			}
    
    			$percentage = $max_percentage;
    		} elseif ( $product->get_type() == 'simple' || $product->get_type() == 'external' ) {
    			$percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
    		}
    
    		if ( $percentage && basel_get_opt( 'percentage_label' )  ) {
    			$output[] = '<span class="onsale product-label">-' . $percentage . '%' . '</span>';
    		}else{
    			$output[] = '<span class="onsale product-label">' . esc_html__( 'Sale', 'woocommerce' ) . '</span>';
    		}
    	}elseif( ! $product->is_in_stock() && !is_product() ){
    		$output[] = '<span class="out-of-stock product-label">' . esc_html__( 'Sold out', 'woocommerce' ) . '</span>';
    	}
    
    	if ( $product->is_featured() && basel_get_opt( 'hot_label' ) ) {
    		$output[] = '<span class="featured product-label">' . esc_html__( 'Hot', 'basel' ) . '</span>';
    	}
    	if ( get_post_meta( get_the_ID(), '_basel_new_label', true ) && basel_get_opt( 'new_label' ) ) {
    		$output[] = '<span class="new product-label">' . esc_html__( 'New', 'basel' ) . '</span>';
    	}
    	if ( $output ) {
    		echo '<div class="product-labels labels-' . basel_get_opt( 'label_shape' ) . '">' . implode( '', $output ) . '</div>';
    	}
    }

    Kind Regards
    XTemos Studio

    #19492

    info@jullo.nl
    Participant

    Wow i really thank you for the extensive code, really appriciate the effort.
    And i know i am far from an expert on this topic, so i bet i gonna say something very stupid right now, but is the word “aanbieding” not pulled from some .po file?

    Wouldnt it be most easy to locate this file and change the suggested translation fro msale to sale? I have Poedit, i just dont know where to find the file which contains the “sale button/banner”.

    #19495

    Artem Temos
    Keymaster

    Yes, but you cannot edit pot file directly. We suggest you to translate it with Loco Translate plugin. You will be able to disable it after changes.

    #20030

    info@jullo.nl
    Participant

    Hi Team,

    I downloaded loco translate. My current website language is set to NL (netherlands)
    and when i try to edit theme, i can find the string sale, but i dont see the translation aanbieding in the context field.

    I also downloaded the pot file, to check if there are any current transaltions already but there are none. Furthermore i find it most strange, that the word aanbieding is no where to be found, and yet wordpress displays it on the frond end.

    What makes this translation to happen automatically? Is it wordpress, is it woocommerce or is it your theme?

    Can you please advise?

    #20033

    Artem Temos
    Keymaster

    Hi,

    You need to check both theme and WooCommerce plugin POT files since there are a lot of texts come with the plugin and only a part of them come with Basel.

    Regards

    #20037

    info@jullo.nl
    Participant

    Ok great, i found it and changed it. And after save I can disable the plugin?

    #20038

    Artem Temos
    Keymaster

    Yes, you can disable the plugin after changes and your POT files should remain.

    #20039

    info@jullo.nl
    Participant

    excellent! thx

    #20040

    Artem Temos
    Keymaster

    You are welcome!

Viewing 12 posts - 1 through 12 (of 12 total)

The topic ‘Change the Translation of SALE button’ is closed to new replies.