-
Notifications
You must be signed in to change notification settings - Fork 64
Conversation
Is there any documentation yet on using mjs files with Nuxt 3? From Nuxt i mean, not in our repo. I'd just like to learn about it a bit more if you know of anything. |
No, I just used whatever WebStorm advised me to do :) Let me look into it. Intlify (the organization behind nuxt i18n) uses The only thing I could find on the official documentation is the advice to 'Avoid commonjs syntax': https://v3.nuxtjs.org/getting-started/bridge#avoid-commonjs-syntax. |
@obulat I think the advise to avoid commonjs syntax for Nuxt3 would only apply to anything that nuxt actually touches. Given that these are external tools that Nuxt doesn't interoperate with (as far as I understand, they're just node scripts) we don't necessarily have to do that conversion here. If the tests ran without a problem with the new syntax it'd probably be fine to do it but considering there are other tooling considerations we can hold off converting to the Jest currently doesn't natively support the Given we could already write our unit test files with that syntax, we can just change the extension back to |
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.
Thank you for fixing this. LGTM as soon as we can, this is pretty critical. I do think we should switch to .js
for now as these files aren't processed by nuxt but are run with node
.
619894f
to
d8b4570
Compare
Fixes
Fixes #317 by @sarayourfriend
Description
This PR replaces the recursive searching for a JSON property in the
en.json
file infindPath
function with the code that first extracts all the full-path JSON keys ( eg.browse-page.search-form.button
) and then for each of these keys saves the relevant information to the POT file.The code for JSON manipulation (key extraction, and value extraction using the full-path JSON keys) was copied from https://github.com/coderaiser/all-object-keys and // https://github.com/coderaiser/jessy .
Previously, the recursive
findPath
function was finding the first available value for property specified. For example, when looking forbutton
, it would findhome.search.button
and use it for any key that hadbutton
in it, even forbrowse-page.search-form.button
. And even though recursive way of finding the property in a deeply-nested JSON was fun, it's easier to debug the current setup :)I had some problems resolving paths and reading a
json
file, and also in light of #313, I replaced thejs
files inlocales
folder withmjs
files. I am not sure it is correct, and would be happy if someone could improve imports/paths.Also, I could not get the
mjs
tests to run :(Testing Instructions
Try to generate the POT file using
npm run i18n:generate-pot
and observe that all values are saved to 'openverse.pot' file correctly. For example, now there exist two different objects for Search button:browse-page.search-form.button
andhome.search.button
, instead of two copies ofhome.search.button
as before.Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin