p2-inc / phasetwo-admin-portal

Other
18 stars 14 forks source link

Add french translations #123

Closed MGLL closed 6 months ago

MGLL commented 6 months ago

Hello,

I did a french translation and adjusted the implementation. If you are interested.

Would it be possible to extend a bit the documentation for environment configuration?

xgp commented 6 months ago

Would it be possible to extend a bit the documentation for environment configuration?

Yes. Please include in the PR.

Thanks for the translations!

MGLL commented 6 months ago

No problem!

Regarding env config, sadly I didn't found how to do it (tried to create an .env file but it wasn't taken into account). So I just modified locally the config.ts so I could test the translation.

Also, I noticed that on page reload, active language was lost, so I did a workaround through localStorage in i18n.ts. Don't know if it's the best way to do it.

xgp commented 6 months ago

@MGLL Sorry for the delay. Hope you are having a good holiday season.

The way locale in the config gets populated is here: https://github.com/p2-inc/phasetwo-admin-portal/blob/main/ext/main/java/io/phasetwo/portal/PortalResourceProvider.java#L171-L180

The code that renders the initial HTML creates an environment variable, which should not change on reload. If that is happening, we should figure out how that is happening and fix it.

MGLL commented 6 months ago

@xgp No problem, yes I hope you too.

Sorry, I wasn't completely clear. The issue I noticed is that i18n.ts is reloaded every time on page reload.

So, every time the translation switches back to English (I don't know why). But if I go back in the user's profile, the locale is pulled again (to populate selectedLocale), and translation changes back to the correct language.

As a workaround, I populate the localeStorage with the user's locale (on locale change and login), and I made i18n.ts rely on it to correctly display the correct language everywhere, even on page reload.

As originally, I'm not a FE developer, I'm not sure that's the best way. I will wait @pnzrr review and see.

pnzrr commented 6 months ago

@MGLL thank you for the great PR. I tweaked a couple things

Give everything a test as well to make sure it works. Other than that I think its pretty much there 🙌

MGLL commented 6 months ago

Hello @pnzrr thanks for the feedback and the adjustments 🙌

I did some tests and it seems to works fine. I have added some translations I missed (in toasts and placeholders).

I wanted to ask, is there a way to populate the environment: Environment from a .env file for local development ? (I'm currently modifying the initialEnvironment: Environment for development.)

From what I see, I guess it's populated by the keycloak server when its packaged in it (with PortalResourceProvider).

pnzrr commented 6 months ago

Great to hear no issues. As of now, modifying that config the way you are doing is ok for local dev. Since it gets injected by the server and that doesn't necessarily happen on local, it's a simple way to mock what you need.

xgp commented 6 months ago

@MGLL Merci!