-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polish i18n support #35
Comments
This should also help with #31 once we get everything polished out. |
It looks like there's a lot of discussion for how to best implement i18n with Next.js (it's something that the creators of the framework have yet to describe official best practices for):
For now, I've got it setup to:
|
What we're doing now is:
We still need to work on:
|
I'm re-opening this because:
|
@nicholaschiang are you currently using |
Not yet @vctormb. Right now, we're still using For instance, in import { useIntl, defineMessages, IntlShape, MessageDescriptor } from 'react-intl';
const msgs: Record<string, MessageDescriptor> = defineMessages({
header: {
id: 'header',
defaultMessage: 'Your profile',
description: 'The header for the profile view.'
},
});
export default function Profile(): JSX.Element {
const intl: IntlShape = useIntl();
return (
<h1>{intl.formatMessage(msgs.header)}</h1>
);
} That's a lot of unnecessary boilerplate code IMHO haha. On a slightly unrelated note, there seems to be an issue with our current static path generation setup where Next.js requires that you specify all paths. See this issue for more info on that. |
Fixes #35 by replacing 'react-intl' with 'next-translate' (which is a lot lighter weight and was made for use with Next.js). Note that we still have an issue using the 'next-translate' <Link> component and that we'll probably want to implement the "build step" as a temporary workaround to enable automatic static optimization for our dashboard pages. We'll probably also add a redirect from '/en' to '/' and get rid of our '/api/redirect' endpoint temporarily (while we don't support any other locales). As soon as we get translations for other locales, however, we'll add it back in.
Goals
We want to be as global as possible which means supporting as many locales as we can find translators for. We need to de-couple the the translation text from our code (i.e. static content should be moved away from the codebase).
Options
I've researched some options for different i18n libraries but they all seem to have their own setbacks:
next-i18next
server.js
which we do not want to do (we won't be able to statically pre-render anything).react-intl
next-i18next
).i18next
react-i18next
For now, I'm going to keep using
react-intl
until I come up against any blocking issues. Note thatreact-intl
also has a Slack workspace which will be good for support concerns, etc.The text was updated successfully, but these errors were encountered: