This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
Fix for compatiblity with the latest version of Lingui #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you so much for creating this example repository, it was super helpful.
I came across this while looking a for a good way to do isomorphic localisation with serverless with Next.js/React and was unable to run it out of the box - I think due to some breaking changes in Lingui- but it was a really great reference. I thought I'd raise this PR to show how I got it working.
Changes in this PR
Fix compatibility with the latest version of Lingui
en.example.com
,fr.example.com
)Changing the module type and using a string replace in
_document.js
is obviously hacky, but it seems to work well. I have not done extensive browser testing, but have tried it in Chrome, Firefox and Safari.Obviously it would be preferable to have either two different build exports or perhaps a UMD module from Lingui but I thought having something that worked (and that worked well with both isomorphic rendering and serverless, which modules like
next-i18next
do not) might help inform ongoing work like lingui/js-lingui#333I am very happy to discuss alternative approaches and to make changes if anyone has any better ideas on how to achieve this. :-) I am also interested in collaborating on some of the issues in #1.
Additional example
I am now using this approach on an experimental site, example URLs:
Source: https://github.com/glitchdigital/glitched.news