How would I do this? Linking two option sets?

Hi all

I have an option set that is a list of language names “arabic, english, russian etc”

When a user creates a thing, one of the fields they choose in a multi-dropdown is one of those language names.

Where I am stuck is here: after such thing is created, depending on the language chosen, I want to trigger google translate api. I know how to do this, but google translate api only uses language codes (en for english, ar for arabic, ru for russian etc). I need to choose these codes dynamically though depending on the language selected when the thing was created. So essentially my question is, how do I link the language names (option set) with their relevant codes so that I can select the language codes dynamically?

Just set an attribute on the option set to store the relevant language code (as a text). Then refer to that in your API calls.

1 Like

Thanks for the reply. I in fact did this but was unable to retrieve the code. Maybe I am a bit confused.

With the Google translate plugin, when I try to access the language code which I set as an attribute to each language, I am faced with two choices. Either:

  1. “This thing’s language” and as it recognizes it as a field in the thing, it doesn’t seem to give me the option to retrieve the code (attribute) of that specific option.

or

  1. “Get an option” choose “Languages”, “'code”. But this seems to randomly choose a language and I don’t see the option to choose the current thing’s language.

I am not a bubble expert so I am probably missing something obvious.

If your Option Set is set up correctly then you should simply be able to refer to the thing’s language’s code wherever you need to.

Maybe post some screenshots of what you’re doing so we can see where you’re going wrong…

1 Like

I got it working. In the thing, I needed to create a field for the language code, separate from the field for the language name.

Thanks for the help!

You shouldn’t need to do that if the code is part of the Option Set. Are you sure the Language field is set to be of the type ‘Language Option Set’?

It sounds to me more like that field is set as a text…

But if it’s working for you then that’s all that matters I guess…

1 Like

You are right. I had the language field set as text instead of Languages. I just deleted those and replaced them and now the code attribute shows as you described. Thanks once again.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.