From e7646a961f7313a13e7e56cc1ea6cb61fefe74b2 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 7 Jul 2020 16:07:49 -0700 Subject: [PATCH] Setup UI - Fix translation of post-install messages 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. --- setup/plugins/installDatabase/SetLanguage.civi-setup.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup/plugins/installDatabase/SetLanguage.civi-setup.php b/setup/plugins/installDatabase/SetLanguage.civi-setup.php index 62543fd29c..0da89b6b89 100644 --- a/setup/plugins/installDatabase/SetLanguage.civi-setup.php +++ b/setup/plugins/installDatabase/SetLanguage.civi-setup.php @@ -14,5 +14,11 @@ if (!defined('CIVI_SETUP')) { 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); -- 2.25.1