Callback to return custom string on MissingTranslationEvent
Open
Nobody has claimed this yet.
type:enhancement
- Dominant language
- PHP
- Stars
- 26
- Forks
- 10
- Avg merge
- 48m
- Merged PRs (30d)
- 1
Description
What steps will reproduce the problem?
$thisMessageIdNotExist = 'xyz';
echo $translator->translate($thisMessageIdIsNotExist);
What do you get?
xyz
What do you want to get?
Oh no, "xyz" is not translated yet!
When event MissingTranslationEvent was triggered I want to return result of my callback not messageId string or fallbackLocale result.
Additional info
| Q | A |
|---|---|
| Version | 1.0.2 |
| PHP version | 8.0 |
| Operating system | KDE Neon |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading src/Event/MissingTranslationEvent.php and tracing where the event is handled during translate(). Verify how the missing message ID and fallback result are selected, then confirm that a callback result can become the returned translation instead; done means the requested custom string is returned for a missing ID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- internationalization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100