Skip to main content
Tweeted twitter.com/StackDrupal/status/1531425301422546945
edited title
Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

How to get the language code when a language name is given?

Source Link
ktrev
  • 139
  • 2
  • 13

How to get the language code when language name is given

We are creating nodes programmatically on submitting a form. The language of a node is an input value in the form. How can I get the langcode, when I have the Language name?

For example, user may type English. So i should convert it to "en"

If there an in-built function for that?