Here's what happens:
- The "Setup" subsystem does its internal/partial bootstrap; it sets `$tsLocale` and uses `CRM_Core_I18n`. Hooray.
- The "Setup" initializes the database/settings and then does a full bootstrap. The full bootstrap step calls `applyLocale()`, which replaces the active `$tsLocale`... with the *unconfigured default*. Ooops.
- This step runs next - and it updates the DB setting. But we've already trampled `$tsLocale`. Calling `applyLocale()` a second time means we use the preferred `$tsLocale` again. Hooray.
if ($e->getModel()->lang) {
\Civi\Setup::log()->info('[SetLanguage.civi-setup.php] Set default language to ' . $e->getModel()->lang);
\Civi::settings()->set('lcMessages', $e->getModel()->lang);
+
+ // Ensure that post-install messages are displayed in the new locale.
+ // Note: This arguably shouldn't be necessary since `$tsLocale` is generally setup before installation,
+ // but it may get trampled during bootstrap.
+ $domain = CRM_Core_BAO_Domain::getDomain();
+ \CRM_Core_BAO_ConfigSetting::applyLocale(\Civi::settings($domain->id), $domain->locales);
}
}, \Civi\Setup::PRIORITY_LATE + 400);