tractorcow-farm / silverstripe-fluent

Multi-language translate module for Silverstripe, without having to manage separate site trees.
BSD 3-Clause "New" or "Revised" License
91 stars 109 forks source link

TextCollector Task throws many Warnings #823

Closed davejtoews closed 3 months ago

davejtoews commented 7 months ago

Module version(s) affected

5,6,7

Description

The output of the i18nTextCollectorTask returns a number of warnings coming from this module. All are of two types:

[User Warning] Error concatenating localisation key
GET /dev/tasks/i18nTextCollectorTask?

Line 737 in /var/www/html/vendor/silverstripe/framework/src/i18n/TextCollection/i18nTextCollector.php
[User Notice] Missing localisation default for key Localisation
GET /dev/tasks/i18nTextCollectorTask

Line 815 in /var/www/html/vendor/silverstripe/framework/src/i18n/TextCollection/i18nTextCollector.php

Each instance of the second appears to be a direct result of the first.

How to reproduce

Run /dev/tasks/i18nTextCollectorTask with the environment set to dev or error reporting otherwise set to display PHP warnings.

Possible Solution

The issue appears to be due to the use of the __TRAIT__ magic constant w/in _t() function calls in FluentAdminTrait, FluentBadgeTrait and FluentObjectTrait. The backslashes in the fully namespaced trait name cannot be parsed.

It should be possible to resolve by replacing all instances of __TRAIT__ with the string name of the class, or a function call which strips the namespace from the result.

Additional Context

No response

Validations

davejtoews commented 7 months ago

This issue was originally flagged here: https://github.com/tractorcow-farm/silverstripe-fluent/issues/656#issuecomment-713666176

GuySartorelli commented 6 months ago

Sounds more like there's a bug in textcollector which should correctly support __TRAIT__.