I have a requirement where in hook_node_insert I need to get the language code of a field

What I have tried is

$langcode = $node->{$field_name}->langcode

But this returns null. Any suggestions?

And is it possible that different fields in a node have different langcode?

  • Use kint to explain $node, there you can find multiple functions to get lan code, must be a function getDefaultLanguage() or so. Jan 9, 2019 at 10:51

1 Answer 1


You can use getLangcode
Try with:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.