• Resolved orion1212

    (@orion1212)


    Hi, first thank you for this great plugin it does a great job!

    I just have a small thing that I couldn’t resolve by myself.

    We are using Polylang and I could not translate the main button, the default “Filters” toggle button. Every other string correctly gets registered in Polylang except this one.

    Usually, I add an unregistered string like this:

    /
    /add soldout badge
    
    add_action( 'woocommerce_before_shop_loop_item_title', function() {
       global $product;
       if ( !$product->is_in_stock() ) {
           echo '<span class="Out_of_stock">' . pll__('Out of stock') . '</span>';
       }
    });
    
    add_action('init', function() {
      pll_register_string('mytheme-hello', 'Out of stock');
    });
    

    But here I’m at a loss as the plugin is not added through function.php

    Here is the code I do have so far:

    // Move filter button before shop’s top row
    
    add_filter( 'awf_js_data', function( $js_data ) {
      $js_data['togglable_preset']['insert_btn_before_container'] = '.kadence-shop-top-row';
     
      return $js_data;
    } );
    
    // Register in polylang
    add_action('init', function() {
      pll_register_string('mytheme-hello', 'Filters');
    });
    

    But as you can see, I am missing the part where I “tell” polylang the button can be translated.

    Would you be able to tell me how to do it?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author annastaa

    (@annastaa)

    Hello Orion1212,

    Thank you so much for your interest in our plugin!

    Unfortunately, we’ve never run any full-scale tests of Polylang compatibility, but at the top of my mind, have you tried using the filters’ language domain in your Polylang function calls, like so:

    // Register in polylang
    add_action('init', function() {
      pll_register_string('annasta-filters', 'Filters');
    });
    Thread Starter orion1212

    (@orion1212)

    Hi Annastaa,

    Thanks your for the answer.

    Unfortunately, it does not work as it (I guess) only shows the string in the interface to translate it but it doesn’t register it. The pll_function as seen in this example needs to be used to wrap the word “Filters”:

    /add soldout badge
    
    add_action( 'woocommerce_before_shop_loop_item_title', function() {
       global $product;
       if ( !$product->is_in_stock() ) {
           echo '<span class="Out_of_stock">' . pll__('Out of stock') . '</span>';
       }
    });

    Would you know how to do it? Unfortunately, my knowledge is too limited.

    Plugin Author annastaa

    (@annastaa)

    Ok Orion1212,

    Before taking the deeper look into the built-in Polylang functions, let’s try approaching this task from a bit different angle. I can see you already use our awf_js_data filter. It actually provides you with an option for a direct edit of the “Filters” toggle button label as well. You can probably use the pll__ function to adjust the label to the current Polylang language before the page load. Try this:

    // Register in Polylang
    add_action('init', function() {
      pll_register_string('mytheme-hello', 'Filters');
    });
    
    // Adjust the button label to the needed language
    add_filter( 'awf_js_data', function( $js_data ) {
      $js_data['i18n']['togglable_preset_btn_label'] = pll__('Filters');
     
      return $js_data;
    } );
    Thread Starter orion1212

    (@orion1212)

    Well, that’s spot on. It’s working flawlessly!

    I appreciate the support and patience, thank you.

    • This reply was modified 1 year, 10 months ago by orion1212.
    Plugin Author annastaa

    (@annastaa)

    Dear Orion1212,

    Thank you for the feedback! Please don’t hesitate to open another thread if you have any further questions about the work of the filters.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Translate main Button’ is closed to new replies.