Autocomplete with multilanguage

8 months 1 week ago #320915 by ericmuc
Replied by ericmuc on topic Autocomplete with multilanguage
Hi,

Ahh, I understand, the autocomplete is such a nice function, I was mentally blocked with it. But for multilanguage a dropdown field, which also is used in search is the solution. Yes, sorry that I didn't saw that on my own.

Thanks, best regards
Eric
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

4 months 1 day ago #323306 by ericmuc
Replied by ericmuc on topic Autocomplete with multilanguage
Hi,
Sorry to coming back with this topic. But I have a further question:

My situation is:
- multilanguage site
- autocomplete with "for example" country
- my goal is to have the entries of the fields with the autocomplete changing due to the current language

A sample:
Country field autocomplete adding "Germ". "Germany" is set in the field. Ok. But if I change from EN to DE the field is "Germany" and not "Deutschland".

My idea hereto was, to set the language variable into the field instead of the language label from the query column. So I changed it and after "Germ" it is set "CB_LANG_GERMANY" in the field. And I added the language variable to the language overrides. I hoped that the system recognize it and show the right language string in the profile. Then I realized, that the content in profile editing is the variable and not a label, that is clear, yes. Not good.

So I m struggling further with this.

The best way would be to have the possibility in a drop down field, to set pairs of id/label with autocomplete with showing the label regarding to the right language and works also with search function.

Is this in some way possible?

Thanks, best regards
Eric

Please Log in to join the conversation.

4 months 11 hours ago - 4 months 9 hours ago #323309 by ericmuc
Replied by ericmuc on topic Autocomplete with multilanguage
Hi,

Now I am a little further:

I have a query drop down field with
SELECT `CB_COUNTRY`,`COUNTRY_NAME` AS 'label' 
FROM `#__country`
WHERE (`LANG` = '[cb:if language_code="de"]DE[cb:else]EN[/cb:else][/cb:if]')
ORDER BY `COUNTRY_NAME` ASC

In the option:
Value Column = CB_COUNTRY (the id of the list)
Label Column = label

By this I have following situation:
- the user can select a country name out of a list in his language
- the right name is shown in his language
- if the user changes the site language the translated right name is shown
- search for the names in different languages works, great!

So this is what I need, but:
- the user has to pick the name out of a list of over 200 names, cannot type in a field with autocomplete
- I have to set the height of the field list in which the names are shown, this height is also shown in search of list and needs too much place there (best would be here to have one line with autocomplete)

So it would be nice to know, what I can do to have the solution I need (and this solution I found in other websites already). Hope, there is a solution for this with the current CB possibilities.

Thanks a lot, best regards
Eric

Please Log in to join the conversation.

4 months 6 hours ago #323316 by krileon
Replied by krileon on topic Autocomplete with multilanguage
Ideally you should just be using a Query Select to build a list of countries to select from and localize the label values while storing standardized ISO-3 in the database.

So this is what I need, but:
- the user has to pick the name out of a list of over 200 names, cannot type in a field with autocomplete
- I have to set the height of the field list in which the names are shown, this height is also shown in search of list and needs too much place there (best would be here to have one line with autocomplete)

If I understand correctly you only want to allow them to select a value and not input a custom one? That's supported out of the box. Within the Auto Complete integrations parameter tab in your field set "Strict Selection" to "Enable".


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

4 months 3 hours ago #323328 by ericmuc
Replied by ericmuc on topic Autocomplete with multilanguage
Hi,
Thanks but my question is as follows:

I have two fields now which I test for the best using by users:

1) text field with query plugin
SELECT `CB_COUNTRY`,`COUNTRY_NAME` AS 'label' 
FROM `#__country`
WHERE (
`LANG` = '[cb:if language_code="de"]DE[cb:else]EN[/cb:else][/cb:if]'
AND `COUNTRY_NAME` LIKE '%[value]%'
)

Case1
Value Column = empty
Label Column = empty

Country in the current language is saved and not translated by switching to another language

Case 2
Value Column = CB_COUNTRY
Label Column = label

Country Code is stored and not translated with other language, in spite of having added the country code in language override (but as I wrote here before the country code is shown in the edit field, that is surely a false way)

So I added a query drop down field
2) Query drop down field
SELECT `CB_COUNTRY`,`COUNTRY_NAME` AS 'label' 
FROM `#__country`
WHERE (`LANG` = '[cb:if language_code="de"]DE[cb:else]EN[/cb:else][/cb:if]')
ORDER BY `COUNTRY_NAME` ASC

Value Column = CB_COUNTRY
Label Column = label

Result: a list of all countries in a field height as set in the field, and translation it is working: country is shown in edit and stored and translation is shown with other language, great

BUT: here is no autocomplete possible and the user has to look by scrolling in a list with over 200 entries, and the list have to be 10 lines high to see soemthing

In addition:
a) I have to add a further list with over 2700 entries and here only autocomplete can be used. But here I need a translation in the appropriate language by switching the language
b) a search shall find the user for example in Germany in all languages, so with "Germany" with EN joomla language and "Deutschland" with DE joomla language

So in my understanding this only works with 2) query drop down field, but here I need an autocomplete.

Hopefully you understand my situation. Is there a possibility to have a solution for this?

Thanks, best regards
Eric

Please Log in to join the conversation.

4 months 3 hours ago #323330 by krileon
Replied by krileon on topic Autocomplete with multilanguage

1) text field with query plugin

That's working exactly as it should. Value does not translate. Label does. Ultimately it's just a text field. So once the option is selected value is added to the text field for storage on save. The only difference between doing this and use typing it themselves is the autocomplete filled it in for them. Beyond that the field will behave exactly as a normal text field would and we do not apply translations to user supplied content.

BUT: here is no autocomplete possible and the user has to look by scrolling in a list with over 200 entries, and the list have to be 10 lines high to see soemthing

Force the field to be a CB Select, which has a filtering feature. You can do this using CB Auto Actions as follows.

Global
Triggers: onBeforeRegisterFormDisplay, onBeforeUserProfileEditDisplay
Type: Code
User: Automatic
Access: Everybody
Action
Method: jQuery
Code:
$( 'select#FIELD_NAME' ).cbselect();
Plugins: cbselect

The only thing you'll need to change is replace FIELD_NAME with the actual name of your field. For example if the name of my field is cb_select I'd use the below. Note if the select is a multiselect then you need to add __ after the field name.

$( 'select#cb_select' ).cbselect();

You can try the below instead if that's not working for you. Replace FIELD_ID with the ID of your field.

$( '#cbfr_FIELD_ID select' ).cbselect();

This works on profile edit and registration views, but can be applied to search as well by adding the onBeforeDisplayUsersList trigger to it.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: ericmuc

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.471 seconds

Facebook Twitter LinkedIn