robisim74/qwik-speak

How can do that, when the i18n file is updated, refresh the page to take effect.

AllenIverson1122 opened this issue · 7 comments

We now have a translation library. When the translation is updated, my json file under i18n will be updated. However, now it needs to be recompiled to take effect. How to set it up? When the i18n file is updated, refreshing the page will take effect.

@AllenIverson1122 Yes, that's not possible, because the translations are inlined at compile-time, not at runtime. So reloading the page is useless.

Could you explain the use case?

  • how is it possible that the translations (only some or all?) are not known at the time of compilation?
  • does a backend server generate them?
  • why not call the server directly and use them? why the extra step of updating files and re-rendering components?

Set a timer and request the api to get translated content once a minute.
When there is a translation update,
execute
fs.writeFile(_i18n +'/' + fileName + '.json', value, function (err) {
if (err) {
console.error(err);
}
})
update i18n/ json file

Set a timer and request the api to get translated content once a minute.

Why would translations change potentially once a minute?

The translation content is modified through the translation system of the translator. After modification, it is polled on the project using qwik-speak. When there is an update, the latest translation is directly replaced and updated, so that it can be updated directly without re-versioning,website will show latest translation content

And what is the expected behavior? Should the user browsing the site see individual translations change without reloading? or is it sufficient that updated translations are available for subsequent navigation?

And what is the expected behavior? Should the user browsing the site see individual translations change without reloading? or is it sufficient that updated translations are available for subsequent navigation?

We expect our translators to submit translations on the translation website, and then I use the qwik-speak website to poll every few minutes for translation updates. When obtained, regenerate the json of the corresponding language under the i18n file. document. When the user reloads the page, he or she can see the latest translation content.
But, now, if I need to update the content, I have to recompile the project and deploy it.

I think your design system expects everything to happen at runtime, while this library and the Qwik framework expects translation to happen at compile time: https://qwik.builder.io/docs/integrations/i18n/. Why were they chosen?

As a side effect you can use this library to get the expected behavior:

Since this will cause performance degradation of your app (directly proportional to its complexity) this usage is not recommended.

I am closing this issue because this request is outside the scope of this library.