0

I'm trying to use the @lit/localize library. I have followed the documentation https://lit.dev/docs/localization/overview/

I've also looked at the sample application https://github.com/lit/lit/tree/main/packages/localize/examples/runtime-ts

What I'm struggling with is that when I pass a parameter for language (http://localhost:3001?locale=es-419) I get the following error

Cannot find module './es-419.js'
 at http://localhost:3001/asset-src_routable-components_UsersScreen_ts.js:54:11

What I have noticed is that if I pass the default language of "en" in the URL the screen loads fine. If i pass junk locale it will give me a different error saying invalid locale code.

It feels like for some reason my locale*.js file is not being built into the project properly. I have followed the link in the comments and tried to add the extensions. But that does not work either

module.exports = (env, argv) =>
 merge(customConfigs(env, argv), {
 resolve: {
 extensions: ['.ts', '.js'],
 }
 });
asked Jul 6, 2023 at 17:59
6
  • Have you run lit-localize build? and make sure your config has the correct outdir and mode. Commented Jul 6, 2023 at 18:02
  • It builds without error. I have added my lit-localize.json file. Commented Jul 6, 2023 at 18:35
  • It's hard to say without seeing the whole project. Do you see the file generate after running the build command? If so this could be webpack failing to resolve the .js extension so checkout stackoverflow.com/a/67929013/19498660 Commented Jul 6, 2023 at 22:25
  • @AugustineKim I re-wrote the question with the issue I'm having now. I feel I'm closer, but still missing something Commented Aug 1, 2023 at 19:19
  • There are a lot of other moving parts that are not shown here. Check the outputDir in lit-localize.json, and see if that's actually in your project directory after running. Does that path match with what you're doing in configureLocalization call? Is your dev server configured to serve those files? Commented Aug 3, 2023 at 0:51

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.