Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds a new
craft\i18n\Translation
class with two static methods:prep()
– Has same arguments asCraft::t()
, but instead of translating the message immediately, it will package the arguments up into a JSON-encoded string prefixed witht9n:
.translate()
– Takes a prepared string fromprep()
and unpacks it, then translates it for the current application language (which could be different than whatever it was whenprep()
was called).All built-in queue jobs are now calling
Translation::prep()
instead ofCraft::t()
when defining their descriptions and progress labels, and the built-in queue driver is callingTranslation::translate()
on job descriptions and progress labels fromgetJobDetails()
andgetJobInfo()
.The result is that queue messages are now always translated for the current user’s language, rather than whatever language was active at the time the job was queued up, or whatever language the queue runner is using.
Examples
Queuing up a job with a custom description:
Defining a default description from a job type:
Setting the progress:
Related issues