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

Change language in backend #404

Closed
kiakahaDZ opened this issue Mar 30, 2023 · 10 comments · Fixed by #559
Closed

Change language in backend #404

kiakahaDZ opened this issue Mar 30, 2023 · 10 comments · Fixed by #559

Comments

@kiakahaDZ
Copy link

Change language in backend does not work such i have verify the code and the execution process but still not understand the issue

@nasirkhan
Copy link
Owner

Can you please let me know a little more details about the issue, like which steps did you followed, how can i regenerate the issue?

@kiakahaDZ
Copy link
Author

Screenshot_1
Screenshot_2
Screenshot_3
Screenshot_4

@kiakahaDZ
Copy link
Author

like the picture if you change the language from one to two others for example from English to Arabic or English to Vietnamese, the words in the dashboard does not translate and are still in the English language, I don't know if I have explain the issue as well

@nasirkhan
Copy link
Owner

thank you for clarification and pointing out the issue.

In Laravel there are two different ways to use localization, first approach is Short Keys and another is using json files. The l10n it working elsewhere expect the menu. You are right that the menu items are not changing. I was using json files for these but if you use short keys then these works. Somehow I overlooked this issue. I will try to fix this soon, of you may submit a pull request if you already fixed it.

I am using "lavary/laravel-menu" for the menu and I just found out that this package has not been updated for Laravel 10. So I will replace this package soon. So if you want till that time, it will be fixed there.

@kiakahaDZ
Copy link
Author

thank you for your response @nasirkhan, for now, the only way that I have found to solve this, is to create a table with one line that contains the updated language, and set the new value of language in the middleware, it's like a session storage based on database, I will search more about the issue and push just when I found an appropriate solution.

@nasirkhan
Copy link
Owner

As i mentioned in the earlier reply, you can use the translations in the middleware if you use the short keys approach. you may find more details at https://laravel.com/docs/10.x/localization#using-short-keys

@kiakahaDZ
Copy link
Author

Yes i have see that but both of translation method does not work, i tried the translation with both method before.

@DeRaja
Copy link

DeRaja commented Oct 13, 2023

Hello Nasir!

Yes this problem in the backend exists in the latest version as of today.

The chosen language does not change on the fly in the backend.

In the frontend, it is not going to change either because the lang parameter is not saved in contents, i.e. in the database. So currently there is only a cosmetic dropdown to cause an effect of change, however not the language. This issue relates also to one issue I have recently raised #506 . Thanks for noting it as an enhancement.

@nasirkhan
Copy link
Owner

@DeRaja ,
the issue reported here and the issue you mentioned in #506 are not the same. The application-related texts will be changed when you switch between languages. However, keeping multiple language versions for content is not within the scope of the Laravel Starter.

If you know how the content language change feature should work and think it is important to have it in the Starter, then please create a separate issue and describe the feature there. I am always for PRs, please submit pull requests if you already developed this feature for your own projects.

@idrisalshikh
Copy link

if you move the session and setLocal middleware from middlewareGroups to middleware that will fix the issue
protected $middleware = [
\Illuminate\Session\Middleware\StartSession::class,
\App\Http\Middleware\SetLocale::class,

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

Successfully merging a pull request may close this issue.

4 participants