flarum / flarum/issue-archive

Translations unavailable in cli after cache clearing

Open
#100 0 comments 0 reactions 0 assignees View on GitHub
type/bug
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Bug Report

**Current Behavior**

On current dev-master (post beta.16) when you `php flarum cache:clear` the `storage/locale` directory is cleared. When you now use the Translator by resolving it from ioc it can no longer use translations.

The reason for this is that:

1. the service providers for Admin and Forum bind the Assets into ioc and there call AddTranslations for their specific frontend.
2. through the AddTranslations the Locale Manager is resolved (causing extensions to load their files) and the catalogue to be cached to disk
3. the console service provider has no logic at all related to this and as such is unable to restore the translations.

Understand that this bugs affects anything executed in cli, including scheduled tasks, cli command but also every single queue job that runs a non-default `sync` driver. Now usually this does not have a huge impact, because most forums regenerate their assets whenever the forum has visitors, but this will result in edge cases that are very hard to explain.

**Steps to Reproduce**
1. run `php flarum cache:clear`
2. create a command that uses the translator to parse a locale string
4. See raw locale string instead of translation

Contributor guide

Open the contributing guide

Research direction

Start with the console service provider and compare its translation setup with the Admin and Forum service providers. Reproduce the issue with php flarum cache:clear, then run a CLI command that resolves the Translator and check how the Locale Manager and catalogue cache are restored. Done means translations remain available to CLI work after the locale cache is cleared.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli, localization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.