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.

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/

  • Thanks, I'll keep that in mind. Currently I'm having issues getting Drush running on my Heroku server. – Neil Nand Sep 18 '18 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 Sep 19 '18 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 Sep 19 '18 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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