Closed fabianlaule closed 8 years ago
Hi, thanks for your contribution
Could you chance the usage of the helper app() and use the instance of the app passing by reference to the constructor? The instance of app you can get on the Service Provider.
Hi,
at first I implemented it like that. But then I found out, that the Contract for the application class doesn't force the classes which implement the contract to provide the methods setLocale/getLocale. So I have to strictly reference the Application class.
I looked in other packages for an appropriate solution and found the usage of the function app().
But If you want to provide the application object as parameter to the constructor, I can implement it this way.
Hi @fabianlaule ,
What do you think about a "callback" feature ?
https://github.com/vluzrmos/laravel-language-detector/blob/develop/src/LanguageDetector.php#L94
That is good enough ?
Released 1.0.10 with callbacks feature.
Today I added your package to a little project (L 5.1 LTS). After I added and configured it, I saw at first no changes with an static page (without translations) and the laravel debugbar. The debugbar showed "en" instead of my locale "de". So I was a little bit confused.
After I added an translation to the view, the view was translated as expected, but the debugbar again showed "en" instead of "de".
After I looked in the sourcecode, I found out that this package only changes the locale on the translator and not directly on the application.
So I changed the sourcecode that the package sets the new locale on application level (
App::setLocale(x)
) which also sets the locale on the translator. So everything works now as expected.I would be thankful if you merge the PR as soon as possible so that I can use it on an other project as well :)
Thank you for the great package!