Question

I am programmatically creating some content during installation of my profile and I need to set the language for this content, otherwise it will be in English(which my site is not) and there will be issues with visibility of fields.

What is the proper way to get the language code in which the site is being installed? The language manager service is returning English, which is incorrect.

Was it helpful?

Solution

Looks like getting it directly from config is working just fine:

\Drupal::config('system.site')->get('langcode')
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top