Skip to content

Feature: Translator return null for missing translations #115

Description

@tomaszkane

What steps will reproduce the problem?

Use Translator on not-existed key.

echo $translator->translate('not.existed.key'); // "not.existed.key"

What is the expected result?

I want to decide when translate() should return key or null.

$translationsForFooCategory = [
  'label.some.existed.key' => 'Hello!',
];

$someOutput =  $translator->translate('label.some.existed.key', category: 'foo');
$someOutput .= $translator->translate('description.some.not.existed.key', category: 'foo');

echo $someOutput; // "Hello!"

Throwing exception on missing translations is to complicated here.

I want to decide if given translate category return null on missing key or given TranlateInterface instance.

Additional info

Q A
Version 3.0.0
PHP version 8.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions