tolgee-js icon indicating copy to clipboard operation
tolgee-js copied to clipboard

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

Open vadimkalaida opened this issue 1 year ago • 11 comments

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

vadimkalaida avatar Feb 06 '24 09:02 vadimkalaida

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

JanCizmar avatar Feb 07 '24 07:02 JanCizmar

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

vadimkalaida avatar Feb 07 '24 08:02 vadimkalaida

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

JanCizmar avatar Feb 07 '24 09:02 JanCizmar

Here is some demonstration:

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

vadimkalaida avatar Feb 07 '24 11:02 vadimkalaida

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?

JanCizmar avatar Feb 07 '24 11:02 JanCizmar

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

vadimkalaida avatar Feb 07 '24 11:02 vadimkalaida

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

JanCizmar avatar Feb 07 '24 12:02 JanCizmar

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 ../.."

vadimkalaida avatar Feb 07 '24 12:02 vadimkalaida

Hey, could you also share the Tolgee initialization?

stepan662 avatar Feb 07 '24 13:02 stepan662

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,
  })

vadimkalaida avatar Feb 08 '24 08:02 vadimkalaida

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());
});

stepan662 avatar Feb 08 '24 14:02 stepan662

Any updates @vadimkalaida?

ZuzanaOdstrcilova avatar Apr 15 '24 08:04 ZuzanaOdstrcilova

Any updates @vadimkalaida?

Just moved from hosted Tolgee, and everything seems fine now

vadimkalaida avatar Apr 15 '24 08:04 vadimkalaida

OK, thanks for reporting. :)

JanCizmar avatar Apr 15 '24 11:04 JanCizmar