yiisoft / yiisoft/translator

Callback to return custom string on MissingTranslationEvent

Open
#66 1 comment 0 reactions 0 assignees View on GitHub

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.

Telegram conversation

Additional info
Q A
Version 1.0.2
PHP version 8.0
Operating system KDE Neon

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.