Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Translation] Extraction of translations does not work (from method transand t)  #53835

Closed
@senaria

Description

@senaria

Symfony version(s) affected

6.4.3

Description

PR #53624 ([Translation] Fix constant domain resolution in PhpAstExtractor) Introduces a new visitor for the PhpAstExtractor, that resolves methods and constant name spaces. See

The problem is that the TransMethodVisitor is unable to handle these namespaces. It is only aware of matching method names.

How to reproduce

  1. Checkout symonfy/symfony
  2. Run composer update
  3. Go to src/Symfony/Component/Translation/Tests/Fixtures/extractor-ast/translatable-short.html.php and replace the second line
 - <?php t('translatable-short single-quoted key'); ?>
+ <?php use function Symfony\Component\Translation\t; t('translatable-short single-quoted key'); ?>

(e.g. importing the function that is used like people would do it in reallife. Just having t() would result in an undefined function 't' and therefore this test case as it is at the moment does not reflect real life)

  1. Run the corresponding tests with php ./phpunit symfony src/Symfony/Component/Translation/Tests/Extractor/PhpAstExtractorTest.php

Possible Solution

There are technically two solutions:

  1. Revert this pull request which breaks the extraction [Translation] Fix constant domain resolution in PhpAstExtractor #53624
  2. Fix the TransMethodVisitor so it can handle the fully qualified namespace of the detected method.

I am happy to invest my time to tackle solution 2, but obiously only if that would be the way to go. Please let me know ASAP

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions