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

NX monorepo, only default translations are served on client in js files when run locally #127

Closed
mhuretski opened this issue May 9, 2024 · 2 comments
Labels
question Further information is requested

Comments

@mhuretski
Copy link
Contributor

Hi,

I'm having a nx monorepo and have a problem with i18n locally.
SSR serves correct values, then they are changed to default values on client. Basically whenever component is hydrated, js files are requested from server and content is always with default values.

I've created empty nx monorepo project with npx create-nx-workspace@latest org-workspace --preset=qwik-nx and added qwik-speak.
Here's empty repo that reproduces the issue https://github.com/mhuretski/nx-qwik-issue-repr.

Steps:

  1. pnpm install && npx nx run test:serve
  2. navigate http://localhost:5173/it-IT/
  3. click "LOCALIZED ALERT"

it's value is going to change from "LOCALIZED ALERT" (IT locale value) to "Alert" (default value).
This issue is not reproducable with normal project without monorepo.

Issue only affects local development, the values are correct in prod mode. So it's something I can live with but it's quite annoying one to have.
I've tried to play around with outDir: '../../dist/apps/test' in qwikSpeakInline options but it didn't help. Could you take a look?

@robisim74
Copy link
Owner

@mhuretski Thank you for this detailed issue and for providing the reproduction!

The problem is the basePath: the default value is ./ (https://github.com/robisim74/qwik-speak/blob/main/docs/inline.md#configure), while in your nx repo it is ./apps/test. Therefore you should update the qwikSpeakInline settings like this:

    qwikSpeakInline({
      supportedLangs: ['en-US', 'it-IT'],
      defaultLang: 'en-US',
      assetsPath: 'i18n',
      basePath: './apps/test'
    }),

Let me know.

@robisim74 robisim74 added the question Further information is requested label May 10, 2024
@mhuretski
Copy link
Contributor Author

Oh, I see, yes, it makes perfect sense, basePath is relative to the root of the project and package has apps/test path.

Thank you very much for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants