-
Notifications
You must be signed in to change notification settings - Fork 157
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
feat: i18n - dynamic import on build time #188
Conversation
@@ -0,0 +1,10 @@ | |||
[ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just moving the code field to the locale files? We could get it from them as well, no need it having additional file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to generate the file, because before it reads on i18n.js, and Settings.jsx file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to refactor it in some way. Explicit build step introduce so much additional caveats and complexity in the long run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If does not want to read the content of the folders at "real-time" (not at building) you need to generate the JSON file. Merge all translations in 1 file I think is not a good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need time to think about it. Anyway, build step should always be at the bundler level
E.g.: https://github.com/egoist/vite-plugin-compile-time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In simple terms, I have some concerns regarding generateLocalesList.js
and frontend/src/utils/localesList.json
.
I suggest making the following adjustments:
The first file, generateLocalesList.js
, should be introduced as a build step plugin.
The second file, localesList.json
, should be generated only after build step and go to build directory. It's important to note that this file should never be committed to the repository since it's considered generated content. There could be some caveats in making it work as expected during the dev stage in Vite. Need to check it how to solve that correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But If you move it to build folder, how can you read it on react files? With fetch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this option could be a solution
https://vitejs.dev/config/build-options.html#build-dynamicimportvarsoptions
https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some vite plugin should handle this. Or another option (more simple one) just to place localesList.json in public directory (I think that it's more suitable location) and gitignore just that file
Anyway, current solution is far better than before, as explicit build step with calling custom script was really confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this option could be a solution https://vitejs.dev/config/build-options.html#build-dynamicimportvarsoptions https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars
But how can you import a file that you generate at build time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
Hi, whats happened with that? |
LGTM, ready to merge. I tested extensively some big changes on my local setup before releasing the production image. I'm really busy with some projects now, so please let me know if that works for your setup as expected |
Do you know why appears this error on error Workspaces can only be enabled in private projects. |
Seems like some errors in yarn.lock. Get the fixed version from main branch. |
I am cloning the repo |
Make sure that you use the latest yarn version (corepack should help)
|
I just tested it, the i18n works perfect |
Please check the type of change your PR introduces: