Skip to content

Feature: Translator return null for missing translations #115

@tomaszkane

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions