phpvms icon indicating copy to clipboard operation
phpvms copied to clipboard

Basic Multilanguage Support

Open ollimaz opened this issue 4 years ago • 11 comments

Added Basic Multilanguage support. Not quite sure how to handle custom pages yet.

To change a the language add ?lang=<<name of folder in /resources/lang>>

adresses issue #740

ollimaz avatar Feb 06 '21 01:02 ollimaz

Hmm I'd rather have the user select the language in their profile and save it in the database, not have it in the nav bar

nabeelio avatar Feb 06 '21 12:02 nabeelio

Yeah that scan in the template won't work, that'll prevent caching of the template and will be very slow. Instead, add a migration to create a new column in the user table called "locale", and then have it in the user profile. Then the middleware can check if the user is logged in and set it that way, otherwise it can fallback with the one the admin has set

nabeelio avatar Feb 06 '21 12:02 nabeelio

I understand. Ok I can do that. But what about users that have no account? or aren't logged in?

ollimaz avatar Feb 06 '21 13:02 ollimaz

Do you think changing the pathing would be better? For example adding a controller to fetch the language from the url. For example .../de/dashboard or /en/dashboard ?

ollimaz avatar Feb 06 '21 13:02 ollimaz

I don't want to change the endpoints. For not signed in/no account, it'll just default to the way it is now - where the admin sets the language statically

nabeelio avatar Feb 06 '21 15:02 nabeelio

Ok totally understand that. I was just wondering because the person i am maintaining the website for told me the website has to support multiple languages as told at https://www.ivao.aero/db/airline/intro.asp . I was told the website has to provide that feature. Because he really wants this system to be used on his ivao registration. But I see its not really shown when these websites have to be translated 🤷‍♂️

ollimaz avatar Feb 06 '21 23:02 ollimaz

Ok and you probably dont want to use packages like https://github.com/ARCANEDEV/Localization ?

ollimaz avatar Feb 10 '21 12:02 ollimaz

Right, it can be done with just some middleware and something on the user table. I haven't looked at that package to see what it can provide but I don't want the routes to be localized.

nabeelio avatar Feb 10 '21 13:02 nabeelio

Ok I'm going to try to come up with a new commit for a multilanguage support with your thoughts. I might be able to create a nwidart/laravel-modules module to create the wished functionality. I am going to close this request and come up with another.

ollimaz avatar Feb 19 '21 22:02 ollimaz

No problem. I don't think you need a new module. It's just simply a new database column in the users table, the profile field to fill out and then middleware to read the user and set the language

nabeelio avatar Feb 19 '21 22:02 nabeelio

And thank you! Message me on discord if you need help

nabeelio avatar Feb 19 '21 22:02 nabeelio