moxystudio / next-intl Goto Github PK
View Code? Open in Web Editor NEWLibrary to integrate react-intl with Next.js.
License: MIT License
Library to integrate react-intl with Next.js.
License: MIT License
Please, update peer dependency range for react-intl to include new version 5
it seems withNextIntl only accepts direct configurations, not plugins!
ex: I attempt to wrap current plugins with withNextIntl but it throws errors
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const withCSS = require('@zeit/next-css');
const withSass = require('@zeit/next-sass');
const nextConfig = {
// target: 'serverless',
webpack(config) {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]',
},
},
});
return config;
},
};
module.exports = withBundleAnalyzer(withSass(withCSS(nextConfig)));
hello next intl works great with pages with server side props or get static props
how ever
i have header.json. (translation for header layout)
page.json (translation for page)
i can import page.json as server side props but how about the header+ its on eveypage
For example, a webpage has two locales, en
and fr
and was first developed with en
with future translations in mind, the website will probably have partial fr
at various points in development, e.g. for testing implementation of next-intl
.
Supporting a fallback feature would make it so message IDs that aren't present in the fr
locale would fallback to their respective messages in en
, after this locale had been set as the fallback default.
This needs to be done in two places:
_document.js
This policy would match against pathnames that start with locales, such as /pt/about
.
Things to consider:
<Link>
component.act
method of this policy would listen to URL changes to check if the pathname need to be corrected with replaceState
.The latest version (v2.0.1
) introduced a bug by calling catch
from the result of p-defer
.
This results in the following error:
TypeError: NextIntlWebpackPlugin.clientDeferred.catch is not a function
at NextIntlWebpackPlugin.apply (<DIR>/next-with-moxy/node_modules/@moxy/next-intl/lib/plugin/NextIntlWebpackPlugin.js:41:49)
at webpack (<DIR>/next-with-moxy/node_modules/webpack/lib/webpack.js:51:13)
at <DIR>/next-with-moxy/node_modules/webpack/lib/webpack.js:36:39
at Array.map (<anonymous>)
at webpack (<DIR>/next-with-moxy/node_modules/webpack/lib/webpack.js:36:24)
at HotReloader.start (<DIR>/next-with-moxy/node_modules/next/dist/server/hot-reloader.js:14:1858)
at async DevServer.prepare (<DIR>/next-with-moxy/node_modules/next/dist/server/next-dev-server.js:6:1541)
at async <DIR>/next-with-moxy/node_modules/next/dist/cli/next-dev.js:22:359
I don't know what bug you were trying to solve by adding that line, but wasn't it supposed to be .promise.catch(...
?
NextIntlWebpackPlugin.clientDeferred.promise.catch(() => {});
If so, let me know and I'll do the PR ๐
I just tried to use this plugin in my app, which is a very basic app.
I get the following error when I try to do npm run dev
error - ./node_modules/@moxy/next-intl/es/polyfill.browser.js:15:0
Module not found: Can't resolve '@formatjs/intl-displaynames/polyfill-locales'
I followed all the steps required not sure why I'm getting the error.
I was getting intl object in previous version. The question is how should i get "intl" object?
Hello,
I'm using Next.js 9.4 and would like to use SSG. Will this module disable it for all my pages?
Best regards,
HK
This code here is a cause of CSP violation: https://content-security-policy.com/unsafe-inline/
next-intl/src/react/NextIntlScript.js
Line 26 in edd7f78
Do you have any recommendation around this issue (except disabling the CSP rule)?
Currently, one knows that a locale has changed whenever we call changeLocale
and attaching to the promise rejection or whenever we use the NextIntlConsumer
or the useNextIntl
hook, because they are re-rendered.
However, it would be nice to register a listener that would cover the case of a locale changing because a policy has changed as well. Moreover, one could also need to register an error handler for whenever a locale change has failed, e.g.: failed to fetch the locale messages. This can be done with a different handler or the same handler by making it similar to node ((err, locale) => {}
).
Hello, i did everything according to the guide. In development mode I got this error
> Ready on http://127.0.0.1:3000 [ event ] build page: /404 [ wait ] compiling ... [ event ] build page: / [ error ] ReferenceError: __NEXT_INTL_POLYFILL_URL__ is not defined
Everything worked after disabling "use strict" in tsconfig. I'm not sure if this is the best way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.