0

I'm trying to automate the setup of Drupal multi-site installations as much as possible, we're using each multi-site for a separate country so would like the languages localised for each.

Is there a way to programmatically set the default language? It normally defaults to English. For a Spanish multi-site I would like to set it to Spanish.

The default language seems to be set in SelectLanguageForm.php .Since this happens so early on in the installation process, I can't use hook_form_alter() because no modules, profiles, or themes would be loaded at that point.

The default language will be defined basing on the subdomain where Drupal is going to be installed.

1
  • did you tried with module drupal.org/project/domain_lang ? this is specifically for the multi sites, but you will also need to install the dependend modules.
    – Ales
    Commented Jan 17, 2021 at 14:25

2 Answers 2

1
drush config:set system.site default_langcode en
1
  • thank you very very much. this has resolved my problem
    – Reza Bayat
    Commented Oct 25, 2021 at 13:51
0

You should consider using Drush (or Bash running Drush) for that. With drush site:install you can set the default language via --locale.

The following command will (re)install Drupal using the expert install profile and set default language to Ukrainian.

drush si expert --locale=uk

Source: https://drushcommands.com/drush-9x/site/site:install/

3
  • Thanks, I'll keep that in mind. Currently I'm having issues getting Drush running on my Heroku server.
    – Neil Nand
    Commented Sep 18, 2018 at 23:37
  • @NeilNand – If you've started your project with Composer (p.e. github.com/drupal-composer/drupal-project) then it's as easy as composer require drush/drush to include it and then cd web and ../vendor/bin/drush si expert --locale=uk.
    – leymannx
    Commented Sep 19, 2018 at 6:07
  • we're using composer and have Drush installed that way, works fine locally, but on Heroku it errors about not being able to fine MySQL which we've not sorted yet. Created a separate question about it on Stack Overflow but with no success as of yet. stackoverflow.com/questions/51858830/…
    – Neil Nand
    Commented Sep 19, 2018 at 10:34

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.