tolgee / tolgee-js

Tolgee JavaScript libraries monorepo
https://tolgee.io
MIT License
218 stars 24 forks source link

Some localized strings are not shown properly on production, but they look just fine locally #3309

Closed vadimkalaida closed 1 month ago

vadimkalaida commented 3 months ago

Recently, we faced a problem: some of our strings did not look like they had to.

This is what it looks like on production:

Screenshot 2024-02-06 at 11 23 05

This is what it has to be (we have it locally):

Screenshot 2024-02-06 at 11 24 12

As you can see, only some of them are not displayed correctly while others are just fine. Honestly, I have no idea why it looks like this

JanCizmar commented 3 months ago

Hello! Thanks for reporting. Can you please share more about your stack? Are you using Tolgee JS SDK?

vadimkalaida commented 3 months ago

Hello! Thanks for reporting. Can you please share more about your stack? Are you using Tolgee JS SDK?

Hello! Thank you for your reply. We use Tolgee i18n library for React – npm i @tolgee/react

JanCizmar commented 3 months ago

Oh, then this has to be trasferred to tolgee-js repository. Anyway, we will need more information about your issue. @stepan662

vadimkalaida commented 3 months ago

Here is some demonstration:

https://github.com/tolgee/tolgee-js/assets/44207160/2fcb4ea8-254c-4125-8f7a-311eac964d89

JanCizmar commented 3 months ago

Are you using Tolgee Cloud or Self-hosted version? I guess this might happen due to using structured export. How are you getting the translations to production?

vadimkalaida commented 3 months ago

We are using Tolgee Cloud, but we are planning to move to Self-hosted version in the near future. File with translations are downloaded during the building process of production

JanCizmar commented 3 months ago

Can you please share how exactly you're exporting the data in the build process, including the code?

vadimkalaida commented 3 months ago

During the building process of production the translations are fetched using this command: "cd public/i18n && curl https://app.tolgee.io/v2/projects/export -H \"X-API-Key: ${VITE_TOLGEE_API_KEY}\" | jar xv && cd ../.."

stepan662 commented 3 months ago

Hey, could you also share the Tolgee initialization?

vadimkalaida commented 3 months ago

Hey, could you also share the Tolgee initialization?

const tolgee = Tolgee()
  .use(DevTools())
  .use(FormatIcu())
  .use(BackendFetch())
  .init({
    language: getLanguage(),
    fallbackLanguage: "en",
    apiUrl: import.meta.env.VITE_TOLGEE_API_URL,
    apiKey: import.meta.env.VITE_TOLGEE_API_KEY,
  })
stepan662 commented 3 months ago

Hmm, that looks OK 🙁 One other thing you can debug is to check how is the tolgee cache looking after you load the data. If you add this piece, it should dump the cache content to the console, so we can check if anything is wrong there.

tolgee.on('initialLoad', () => {
  console.log(tolgee.getAllRecords());
});
ZuzanaOdstrcilova commented 1 month ago

Any updates @vadimkalaida?

vadimkalaida commented 1 month ago

Any updates @vadimkalaida?

Just moved from hosted Tolgee, and everything seems fine now

JanCizmar commented 1 month ago

OK, thanks for reporting. :)