Open borys-p opened 6 years ago
Thanks for the info. Maybe @eusonlito (creator of the laravel-Gettext package) knows other workaround
I'm using the package with a require before vendor/autoload.php
on public/index.php
and artisan
command.
# public/index.php
require __DIR__.'/../vendor/gettext/gettext/src/translator_functions.php';
require __DIR__.'/../vendor/autoload.php';
# artisan
require __DIR__.'/vendor/gettext/gettext/src/translator_functions.php';
require __DIR__.'/vendor/autoload.php';
Regards, Lito.
Yes, that's another solution. But it's... inelegant. You make a strong coupling with a vendor library, while Laravel recently introduced auto-discovery feature to reduce this.
To be honest, the Composer hack isn't much better, but in theory Gettext could control it. If only there was a way to force Composer to include translator_functions.php
before Laravel's helpers then it would fix this issue (I assume that if you include Gettext into Laravel, then you don't care about the built-in __()
function).
Is not the best way to do it, but it's almost clear.
Laravel __
is loaded as helper function after check if not exists: https://github.com/laravel/framework/blob/4c9915c666c9cc085f5c749d640bcf0d309a64a5/src/Illuminate/Foundation/helpers.php#L926
Hi,
It seems that both Gettext and Laravel are defining
__()
function. Although Laravel wraps their definition withfunction_exists()
, it's not normally possible to register Gettext's functions before Laravel'shelpers.php
is loaded, as it's automatically included with Composer.The only solution I've found so far (other than messing in vendor files) is https://github.com/funkjedi/composer-include-files.