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 translator component in a View? #143

Open
drjoju opened this issue Apr 23, 2020 · 3 comments
Open

How to use translator component in a View? #143

drjoju opened this issue Apr 23, 2020 · 3 comments

Comments

@drjoju
Copy link

drjoju commented Apr 23, 2020

Please, anyone knows how to use the translator component in the view component?

In Laravel I use the helper funcion but I don't know how to do it in this view component.

An example in the index.php of the view could be interesting.

Thanks and best regards

@Gummibeer
Copy link
Contributor

I will check if I get something together.
One way would be to share() the translator itself as $trans or similar.
The second idea I have is a global function that uses your container and/or the translator instance.
I will see if I can come up with runnable code.

@LouisGac
Copy link

any news on this one?

@LouisGac
Copy link

    $trans = new Translator($loader, $locale);
    $container->instance(\Illuminate\Translation\Translator::class, $trans);
    $container->alias(
        \Illuminate\Translation\Translator::class, 
        (new class extends \Illuminate\Support\Facades\Lang {
            public static function getFacadeAccessor() { return parent::getFacadeAccessor(); }
        })::getFacadeAccessor()
    );

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

3 participants