statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.06k stars 530 forks source link

Statamic may get forced into English only through addons #3127

Closed jelleroorda closed 9 months ago

jelleroorda commented 3 years ago

Bug Description

Basically I've figured out what caused our CP to 'suddenly' use the English translations. This has to do with using the laravel translation helper before the Statamic translation stuff has been properly booted (it seems). So basically the issue is doing something like __('Some translation') in the boot method of an addon service provider or your own service provider. It's likely that an addon will be booted before Statamic since package autodiscovery is a thing.

For more information also see aryehraber/statamic-impersonator#8

How to Reproduce

See aryehraber/statamic-impersonator#8 for an actual use case.

Environment

Statamic 3.0.37 Pro Laravel 7.30.1 PHP 7.4.11 aryehraber/statamic-impersonator 2.0.0 statamic/seo-pro 2.1.0

aryehraber commented 3 years ago

Hi gents! Just wanted to follow up on this; I just received another issue on my Logbook addon with the same problem as stated above. Both Utilities are booted as documented in the dev docs but perhaps, as @jelleroorda already pointed out, this needs some slight adjustments due to packages booting in the wrong order?

Should the Utility registration be deferred via the booted callback as shown in the issue: https://github.com/aryehraber/statamic-impersonator/issues/8#issue-787155606

Once there's a clear/recommended way forward I'll apply to all my Utility addons. Thanks!

duncanmcclean commented 9 months ago

Hey 👋

I'm unable to reproduce this issue on the latest version of Statamic. I believe it may have been fixed by #7343.

I'm going to close this issue now. If you're still experiencing this issue, please leave a comment and we can re-open the issue. Thanks!