Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter theostefou

    (@theostefou)

    Hi again, I am replying with my solution for anyone interested.

    You will have to copy the following file on your server:
    /wp-content/plugins/filter-everything/views/frontend/chips.php
    to
    /wp-content/themes/YOUR_THEME_FOLDER/filters/chips.php
    e.g. my theme is astra, so the path is
    /wp-content/themes/astra/filters/chips.php

    Starting at line 30, there is a span element with the class ‘wp-chip-content’
    The idea is to write code that replaces the text of the min and max price chips if the selected language is (in my case) greek. The greek locale code is ‘el’

    <span class="wpc-chip-content">
    <?php
    $chip_name = $chip['name'];
    if(get_locale() == 'el' && array_key_exists('label', $chip) && $chip['label'] == 'Filter by Price') {

    if(str_contains($chip_name, 'Min price:')) {
    $chip_name = str_replace('Min price:', 'Ελ?χιστη τιμ?:', $chip_name);
    }
    else if(str_contains($chip_name, 'Max price:')) {
    $chip_name = str_replace('Max price:', 'Μ?γιστη τιμ?:', $chip_name);
    }

    }
    ?>
    <span class="wpc-filter-chip-name"><?php echo esc_html( $chip_name ); ?></span>
    <span class="wpc-chip-remove-icon">×</span></a>
    </span>

    ‘Filter by price’ is the title of the filter. In the option ‘Labels for chips’ of the filter’s menu I have:
    Min price: {value} €
    and
    Max price: {value} €

    ‘Ελ?χιστη τιμ?:’ is the greek translation for ‘Min price:’, do the same for ‘Max price:’ …

    Finally, instead of echoing $chip[‘name’] we now echo $chip_name, which might have been changed if the locale matches the one we are translating and only for this specific filter.

    • This reply was modified 1 month, 1 week ago by theostefou.
    Thread Starter theostefou

    (@theostefou)

    Hi @fesupportteam!

    Since I’m familiar with writing code, this doesn’t seem that difficult, thank you for the recommendation. However, I’m not too familiar with how WordPress updates work. My question is, if the plugin is updated, will my code be overwritten and would I have to reapply the changes? I suspect the answer is yes, not a big deal, I just need to be aware of this.

    I would also like to point out that for the “Search Term” chip, this works as expected. That is, Translate Press detects a template string: “search: %s”, %s being the portion of the string being replaced by the search term.

    To anyone else interested in this: I will reply to this thread once I have working code for this, so that other people can copy it. Keep in mind, I’m not a PHP expert by no means though.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)