next-with-lingui icon indicating copy to clipboard operation
next-with-lingui copied to clipboard

Notes

Open tricoder42 opened this issue 6 years ago • 6 comments

Hey @disintegrator, this looks really awesome!

I tried to improve it, but LinguiJS is missing few features:

  • to support reloading of messages without page refresh @lingui/loader need to receive a parameter, because for initial render we need compileNamespace=window.LINGUI_INIT, but for dynamically loading catalogs we need regular cjs or es export.

  • lingui extract --watch (or lingui watch) would be very useful to automatically extract messages.

  • i18n object could have method onLocaleRequest, where you could register callback (e.g. dynamic load of catalog) if locale is changed. Then we could use i18n.activate('en') to change active locale

So, I think for now you did the best what you can. I'll take a look next week how we could improve LinguiJS API to provide smoother implementation in SSR apps.

tricoder42 avatar Sep 21 '18 12:09 tricoder42

Can't believe I forgot to say this sooner... Thank you for checking this work out! It's really great to have your support 🙂

disintegrator avatar Oct 01 '18 10:10 disintegrator

Is there any progress on this issue? I am wondering how to edit the implementation to

support reloading of messages without page refresh @lingui/loader

cjayyy avatar Jan 28 '19 17:01 cjayyy

Not directly, but I've just bootstrapped a Next.js project couple of days ago. I'm learning to use and understand the framework while working on LinguiJS v3. So, there is a progress, but still nothing specific. I should have more info in next few weeks.

tricoder42 avatar Jan 28 '19 17:01 tricoder42

Awesome, can't wait to see the results. Please refer to this thread in case of any ideas.

Thanks so much for great Lingui and your precious time! Love it :)

cjayyy avatar Jan 28 '19 19:01 cjayyy

@disintegrator @tricoder42 Hi both!

Thanks so much for your work!

  • I've raised at PR at #3 that relies in a hack to fix the current example, but might be a helpful part of the journey to work out a better approach (it seems there was a change in Lingui recently which has broken this example, but this addresses it, in a slightly terrible way but that I think is helpful to highlight the problem).
  • What's great about Lingui and this example repo is that it works really well with both isomorphic rendering and serverless (and is much less opinionated that other projects, which have dependancies like express, which in turn impact bundle functions and being able to run serverless on the edge, etc).
  • Perhaps either Linqui could generate multiple outputs to facilitate easier isomorphic rendering + SPA support, or export a UMD module, or just a script that works in an isomorphic way by checking it's environment (I have had success with both approaches on different modules).

I'm happy to contribute to other items on this list if we can wrangle the this example back to a working state! I'm also hoping there is something I am missing about exports that someone can suggest when they see the problem. :-)

iaincollins avatar May 25 '19 10:05 iaincollins

BTW, as announced at ReactEurope by @timneutkens, Next.js will have /api/ route support, which I think will be great for making it easy to facilitate loading catalogs in a Single Page App.

e.g. You could call an endpoint via fetch and have your app fetch and load a new catalog at run time without an app reload.

When this is working again (and the functionality settled) it would be great to see this example in next.js/examples, especially as it works so well with serverless deployments.

iaincollins avatar May 25 '19 11:05 iaincollins