• Resolved exc1usive

    (@exc1usive)


    Hi Roland,

    We have a problem to change language of your plugin. We use WPML plugin to switch language on our site, and we have set constant in our functions.php file as it says in your documentation.
    define( 'PDB_MULTILINGUAL', true );
    We expected all predefined texts in your plugin, such as buttons – clear, save, cancel and so on, service messages and etc., would change its language on that switch. But it’s not. So, since we should translate user-defined strings manually, we decided to use our own parser in pdb-translate_string filter. And here come difficulties.
    We use your Combo Multi Search plugin.

    1) One of the fields on that form is Multiselect Checkbox. And the search value(s) for this field does not get translated. So, the function $PDb_Combo_Multi_Search->current_search_term(), will return all search values from the form fields, where values from Multiselect Checkbox field still in default language, and values from other fields are in selected language. After examining object $PDb_Combo_Multi_Search, I found out that search value for this field held in format “,value1,value2” or “,any,value1” or “,value1”. I’m not sure about purpose of this leading comma. My wild guess is the whole string passed to pdb-translate_string filter – “,value1,value2”, and not individual search values – “value1”, “value2” and so on.

    2)In your multisearch template you have defined buttons in the following manner.
    <input type="submit" class="button-secondary" name="multisearch-submit" data-submit="clear" value="<?php echo $PDb_Combo_Multi_Search->i18n['clear'] ?>" />
    So, we replaced $PDb_Combo_Multi_Search->i18n[‘clear’] with the call of our parser to get translation for “Clear” button, and now, the button only works in English. My guess is you use value attribute of input field to determine which button is clicked, and since our translation for this button differs from the value you compare to, the button does not clear the search form.
    Also, I found another interesting info while examining you $PDb_Combo_Multi_Search object. The array where you pull your translated string from $PDb_Combo_Multi_Search->i18n always has english values in it.

    [i18n] => Array
            (
                [clear] => Clear
                [search] => Search
                [any] => Any
            )

    But, if you look at your another version of i18n array, it contains values depending on selected language, and actually this array has more elements than the one mentioned above.

    $PDb_Combo_Multi_Search->search->Query->i18n
    
    [i18n] => Array
    (
        [delete_checked] => Markierte löschen
        [change] => Aktualisieren
        [sort] => Sortieren
        [filter] => Filtern
        [clear] => Leeren
        [search] => Suchen
    )

    Any ideas what can cause this behavior?
    Let me know if you need more info.

    Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter exc1usive

    (@exc1usive)

    Thank you for your response. It solves the problem from my second question.
    What about the first one, when the search form has Multiselect Checkbox options?

    The options on the form got translated, but in the text with search terms the filter remain their default values.
    Here is an example how it looks on the page. This is English version:

    Found 1 result while searching for Electrical fitter, Germany, Austria.

    And this is the German version of the same search:

    1 Ergebnisse bei der Suche nach Electrical fitter, Deutschland, Österreich gefunden.

    The search terms – “Germany, Austria” come from Multiselect Dropdown fields, and they got translated. The search term – “Electrical fitter” comes from Multiselect Checkbox field, and values are always in English (default language).
    To translate user-defined strings we use parser in pdb-translate_string filter. As I stated before, it might happened because of leading comma in search terms for Multiselect Checkbox field.

    • This reply was modified 6 years, 8 months ago by exc1usive.
    Plugin Author xnau webdesign

    (@xnau)

    With any kind of selector form element, the plugin provides a way to set up a “display” value (which can be translated) that is associated with the “stored” value, which is not.

    In a multilingual setup, you are expected to set up your selector fields with display values that have the the languages embedded in the string. For example if the value is “blue”:

    [:en]Blue[:es]Azul[:de]Blau[:fr]Bleu[:nl]Blauw[:]::blue

    (this example uses the Q-Translate syntax, your syntax may be different)

    The value saved is “blue” but the user will see the label in their own language. When they search in their own language, the word they use is indexed to the options and matched to the value in the database. This way, it doesn’t matter what language they are using, it will match the corresponding value that is stored in the database.

    Thread Starter exc1usive

    (@exc1usive)

    Yes, I understand that. We have used Q-Translate for awhile, and, unfortunately, it didn’t fill all our requirements and we decided to use our own parser where we pull translated string from the database. It works well all around except for search terms in the line mentioned in previous post.
    Actually, I just found out another reason why it might happened. It happens only to a string which consists of two or more words (contains spaces). It doesn’t matter if the field is Multiselect Checkbox or Multiselect Dropdown, I tried both. It only depends on spaces in the string. For example,

    1 Ergebnisse bei der Suche nach Electrical fitter, Schweisser, Estland gefunden.

    Where, Schweisser and Estland consist of one word and they got translated, and “Electrical fitter” has space in it, and got not translated, but only in search terms text. Everywhere else it gets translation.
    Any ideas what I might be doing wrong?

    Plugin Author xnau webdesign

    (@xnau)

    You may need to use the “whole word” option. It can be difficult to match multiple word search terms to the correct option.

    Generally, it is more reliable to use a “multisearch” field when users are searching on fields that are selectors, so that specific options can be chosen by the user instead of the plugin having to search for a matching option from the “combo” input.

    Thread Starter exc1usive

    (@exc1usive)

    I don’t quite understand your answer. I didn’t say anything about “combo” input, we don’t use this type of search. All fields on the search form are fields with selectors – Multiselect Checkbox, Multiselect Dropdown, and Dropdown List. The only exception is Currency field where a user makes manual input in “from”-“to” fields.
    We don’t set any settings on “Combination Search Settings” tab. We provide search fields list in “Multi Search Fields” on “Multi Search Settings” tab. I just tried to set a checkmark for “Whole Word Match Only” setting on “Multi Search Settings” tab, but it didn’t do anything. The search itself works fine, it produces the correct list of participants. The only problem with the translation of “multiple word” search terms in the string

    Found 1 result while searching for Electrical fitter, Germany, Austria.

    Everywhere else this “multiple word” option gets its translation.
    So, this Multiselect Checkbox field has following options defined “General worker, Mechanical fitter, Electrical fitter, Pipe fitter, Welder”. Only “Welder” from this list gets its translation, since it’s a single word option. Once again, we are talking about search term translation only in this string “Found %d result while searching for %s”, everywhere else all options get their translations.

    The only workaround I can think of is to set up a “display” value and use only single-word values. In this case everything should work correctly.

    General::General worker, Mechanical::Mechanical fitter, Electrical::Electrical fitter, Pipe::Pipe fitter, Welder::Welder

    I think this limitation should be included in documentation.

    Thread Starter exc1usive

    (@exc1usive)

    I just tried to set up “display” values as I described above, and it didn’t work. It looks like it doesn’t even trying to get translation for “multiword” options. It always returns their “stored” values.
    I set my options list like this:

    General worker, Mechanical fitter, Electrical fitter, Pipe::Pipe fitter, Welder

    In the database I changed English translation for key “Pipe” to value “Pipe fitter123”, and everywhere on the site I see “Pipe fitter123”. But, in the search terms string it says:

    Found 7 results while searching for Electrical fitter, Pipe fitter, Welder.

    It supposed to be “Pipe fitter123” and this means that for “multiword” search terms it always returns the stored values(Pipe::Pipe fitter). I could understand if the search term would be equal the “display” value “Pipe”, but it’s not.

    The question is still open.

    Plugin Author xnau webdesign

    (@xnau)

    OK, thanks for the additional detail, I wasn’t sure exactly what you were seeing. Is it true that this issue is only seen in the search result feedback?

    Thread Starter exc1usive

    (@exc1usive)

    By search result feedback you mean this string template “Found %d result while searching for %s”?!))) If yes, than yes – so far, I came across this behavior only in the search result feedback.
    If more precise, I would say you may see it in the returned by the function $PDb_Combo_Multi_Search->current_search_term() value.

    Plugin Author xnau webdesign

    (@xnau)

    OK, I think I found the problem. You can fix this by making a change to one of the plugin files.

    In classes/PDb_Form_Element.class.php on line 801, you’ll find:

    } elseif ( str_replace( ' ', '', $option_value ) === $value ) {

    change that to:

    } elseif ( $option_value === $value ) {

    and it will correctly send the title string through the translate filter.

    This change will be included in the next update. Thanks for you help finding this bug.

    Thread Starter exc1usive

    (@exc1usive)

    I confirm, this change fixes the problem.
    Waiting for the update.

    Thank you very much for your cooperation!

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

The topic ‘multilingual site’ is closed to new replies.