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

App::setLocale does't work. #205

Closed
larvldeltacoding opened this issue Feb 2, 2021 · 5 comments
Closed

App::setLocale does't work. #205

larvldeltacoding opened this issue Feb 2, 2021 · 5 comments
Assignees
Labels

Comments

@larvldeltacoding
Copy link

I'm using 11.9 version of laravel-translatable, laravel 5.8. and php 7.4

I want to use this example but it does't work:

App::setLocale('de');
echo $post->title; // Mein erster Post

if I do $post->translate('de')->title than it works.

Do you have any idea why it is not working for me with only echo $post->title?

@AlbertoSinigaglia
Copy link

Same

@AlbertoSinigaglia
Copy link

EDIT:
I solved removing this value:

/*
    |--------------------------------------------------------------------------
    | Default locale
    |--------------------------------------------------------------------------
    |
    | As a default locale, Translatable takes the locale of Laravel's
    | translator. If for some reason you want to override this,
    | you can specify what default should be used here.
    | If you set a value here it will only use the current config value
    | and never fallback to the translator one.
    |
    */
    'locale' => null, // previously was set to a language

Check this issue #148

@larvldeltacoding
Copy link
Author

Thank you, works as expected! It would be nice to know why it has to be null... hope somebody from contributors will explain it.

@AlbertoSinigaglia
Copy link

@larvldeltacoding you're welcome... idk

@Gummibeer
Copy link
Member

Hey @larvldeltacoding ,
the packages locale config is if you want to manage the used locale totally separated from the app locale.
It's also described like this in the config description:

If you set a value here it will only use the current config value and never fallback to the translator one.

@Gummibeer Gummibeer self-assigned this Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants