How to get the language from a languageselector?

I would like to store the language in an app state variable depending on the selection from a languageselector. How can I do that?