Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Ensure default_locale to en_US #11570

Open
wants to merge 1 commit into
base: 5
Choose a base branch
from

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Jan 21, 2025

Issue silverstripe/.github#357

For whatever reason, CMS 5 sink now uses cwp/cwp-core 3.x-dev instead of 3.0.2, and 3.x-dev sets the default_locale with yml rather than _config.php silverstripe/cwp-core@3.0.2...3

This causes a few i18n tests to fail https://github.com/silverstripe/recipe-kitchen-sink/actions/runs/12877846807/job/35902983644#step:12:334

Also causes a locale date test to fail - Failed asserting that '29/02/2020, 17:00' matches PCRE pattern "#2/29/20,\h5:00\hPM#iu". https://github.com/silverstripe/recipe-kitchen-sink/actions/runs/12877846807/job/35902983814

Note that CMS 6 doesn't have this issue as cwp-core is no longer in CMS 6 sink

New CI sink run with this PR and also this PR https://github.com/creative-commoners/recipe-kitchen-sink/actions/runs/12899443197 (broken behat test is unrelated)

@GuySartorelli
Copy link
Member

This will affect project unit tests as well - please make sure to add a quick note about this in the 5.4 changelog.

@@ -282,7 +282,9 @@ protected function setUp(): void

// i18n needs to be set to the defaults or tests fail
if (class_exists(i18n::class)) {
i18n::set_locale(i18n::config()->uninherited('default_locale'));
$defaultLocale = 'en_US';
i18n::config()->set('default_locale', $defaultLocale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing the config here? We don't need to set the active locale, done we?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requirements_Backend::add_i18n_javascript() reads i18n::config()->get('default_locale') directly, it's what caused the unit test to fail in the first place

@GuySartorelli
Copy link
Member

I've just realised why i18n::config()->get('default_locale') was being used - projects can of course run unit tests, and will likely want to run those tests against the default locale they have set for their project.

@emteknetnz emteknetnz force-pushed the pulls/5/default-locale branch from ca79a73 to ce43f89 Compare January 21, 2025 23:54
@emteknetnz emteknetnz force-pushed the pulls/5/default-locale branch from ce43f89 to 6f2b81c Compare January 22, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants