next-with-lingui
next-with-lingui copied to clipboard
Notes
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 needcompileNamespace=window.LINGUI_INIT
, but for dynamically loading catalogs we need regular cjs or es export. -
lingui extract --watch
(orlingui watch
) would be very useful to automatically extract messages. -
i18n
object could have methodonLocaleRequest
, where you could register callback (e.g. dynamic load of catalog) if locale is changed. Then we could usei18n.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.
Can't believe I forgot to say this sooner... Thank you for checking this work out! It's really great to have your support 🙂
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
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.
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 :)
@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. :-)
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.