next-translate | js plugin i18n API | Internationalization library
kandi X-RAY | next-translate Summary
kandi X-RAY | next-translate Summary
The main goal of this library is to keep the translations as simple as possible in a Next.js environment. Next-translate has two parts: Next.js plugin + i18n API.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of next-translate
next-translate Key Features
next-translate Examples and Code Snippets
Community Discussions
Trending Discussions on next-translate
QUESTION
Today, in my side-project, I got a problem relate to setup getStaticPaths of multi-locale dynamic pages in Next.js. I researched and find out that there are so many people stuck in this problems.
I have created a dynamic page [slug].js to handle all dynamic datas I got from a database. And my website I was working on is also multi-language website which is using next-translate for handle i18n.
In [slug].js, we have to setup a function getStaticPaths to handle all static url. It will be more easier if the website got 1 language, but with more than 2 languages we have to loop it.
...ANSWER
Answered 2021-Jun-01 at 19:08Here is the code I have been used to handle it, I was working with Notion API and use it as a database for a multi-language website:
QUESTION
I'm using next-translate
. By default, my routes are recognized as follows:
ANSWER
Answered 2021-Apr-26 at 10:59The fact that the persisted NEXT_LOCALE
cookie doesn't automatically redirect based on its value is because you have explicitly disabled it by setting localeDetection: false
. This affects the header-based redirection as well as the cookie-based one.
Simply removing it from your next.config.js
should solve that issue.
QUESTION
I'm struggling to understand the correct way or BEST WAY to deploy nextjs app. I have a hybrid Nextjs website which I currently host on Azure App Service. So far I run
- npm build
- npm start The app compile with no error and I host on Azure all the content of my application which contains
- .next/
- components/
- pages/
- ...all configs
- ..all js files
Looking from Nextjs documentation (which is kind of slim on this topic), seems that this is the right way to do it.
From my understanding tho, just the .next/
folder should be needed for production, since is the one that has bundled code. The pages/
, components/
and so on, should be used just on development mode.
I also found some other examples online that go in this direction. If i try to remove /pages or /components tho, I got error and the app cannot run any more.
Can someone confirm me what is the minimum file structures needed for Nextjs application on production?
UPDATE:
The error I get is first:
ENOENT: no such file or directory, i18n
When I add this file, then I get the error:
ENOENT: no such file or directory, pages/
i18n.js
is a configuration file for the packages next-tralsation
https://github.com/vinissimus/next-translate
I'm talking with the author there as well, it might be a problem on their end, but right now I just want to know if na hybrid Nextjs.js app in production should include pages/
folder.
I want to know if .next/
folder is enough for production deployment and if not, i would like to understand why.
ANSWER
Answered 2021-Feb-18 at 10:51There is an example of usage with Docker in official repo https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile.multistage
But I guess it applies for non-docker environments too.
Basically, it builds application and only keeps this files and folders after that:
- package.json
- next.config.js
- .env*
- public
- .next
- node_modules
So no, pages
should not be needed after build for vanilla NextJs app, but it might be needed for something else maybe, like next-translate
package in your example, I am not quite sure how it using pages
and what for.
QUESTION
I'm the author of next-translate library, and I'm working on an experimental version to which I get an error with React 16.14.0 and I don't understand why it happens. Upgrading React to version 17 then it works fine, but I don't want to force everyone who uses the new version of my library to migrate their React version.
I've created a reproducible error example: https://github.com/aralroca/next-translate-error-reproduction
In order to reproduce this issue:
- Clone this repo
- Run
yarn && yarn dev
- Open
localhost:3000
- Open devtools
Error was not caught ReferenceError: exports is not defined
And the prerelease code of my lib is here:
tsconfig.json
...ANSWER
Answered 2020-Nov-24 at 08:19I've already fixed it, but if I'm honest, I haven't understood why... Let's see if someone can explain it to me!
I was debugging and saw that it was something in my library code that caused TypeScript to compile badly. So, I was uncommenting line by line, until I saw what was wrong with the line:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install next-translate
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page