Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use global __() function? #11

Open
mexn opened this issue Sep 30, 2019 · 3 comments
Open

How to use global __() function? #11

mexn opened this issue Sep 30, 2019 · 3 comments

Comments

@mexn
Copy link

mexn commented Sep 30, 2019

Hi!

I just found your plugin and was wondering, if you found a way to use Gettext's global __() function instead of Laravel's (setting config-option functions to true)? Because I struggled doing so, whether I'm trying my own solution or using your package.

vendor/gettext/gettext/src/translator_functions.php:
Cannot redeclare __() (previously declared in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:907)
@eusonlito
Copy link
Owner

You should add the gettext functions file before load vendor autoload:

# public/index.php

require __DIR__.'/../vendor/gettext/gettext/src/translator_functions.php';
require __DIR__.'/../vendor/autoload.php';

and same into artisan.php:

require __DIR__.'/vendor/gettext/gettext/src/translator_functions.php';
require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';

@mexn
Copy link
Author

mexn commented Oct 1, 2019

Thank you, I had hoped you have found a different way I'm not aware of yet.
But this approach makes the functions config setting non-functional, or do i miss the point here?

@eusonlito
Copy link
Owner

Yes, using this approach the functions setting is not functional, but this way is needeed because laravel functions are load before any other package file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants