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

Allow to restrict some parts of the i18n file to unauthorized users in SvelteKit. #239

Open
kyngs opened this issue Nov 10, 2023 · 3 comments

Comments

@kyngs
Copy link

kyngs commented Nov 10, 2023

Is your feature request related to a problem? Please describe.
I have two parts of my web app, one is public and the second is private hidden behind a login form. If you read the i18n file (which you can access even if you're unauthorized), you can approximate what the private part looks like.

Describe the solution you'd like
Be able to separate JSON for one locale to different files and restrict some of them.

Describe alternatives you've considered
My current solution is to load the admin JSON in my +layout.server.ts and then load it into svelte i18n in my +layout.svelte

The second alternative is to leave as-is and hope no one digs too deep.
How important is this feature to you?
Quite a lot, because I don't want people to know what the private part of the web app looks like.

@LVitus
Copy link

LVitus commented Jan 23, 2024

Same here, I think this is of great importants.

A good approach would be to only load the translations for the keys used on the loaded page. This would also improve performance for larger dictionaries.

@TimKieu
Copy link

TimKieu commented Apr 26, 2024

@kyngs @LVitus after authorized into private routes, you can call addMessages() to add your sensitive translation dictionary from DB or protected API or from server side via data props on load() of those private +page.js

@kyngs
Copy link
Author

kyngs commented Apr 26, 2024

@kyngs @LVitus after authorized into private routes, you can call addMessages() to add your sensitive translation dictionary from DB or protected API or from server side via data props on load() of those private +page.js

Yeah that's basically what I ended up doing.

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