If don't want to use 3rd-Party Library like i18n. This is the easy solution to create Multi-Language Next.js website using only JSON.
Before start the solution, you can Download the below source code on my github repo.
1.Create JSON file
In JavaScript, we can set a JSON object on a variable.
To make it work well on a framework, we need to create a locale/ directory first. Then create [language] directory and common.json inside the [language] directory.
2.Import JSON Object
Import common.json to our define variable and make it separate variable for separate language.
3.Set Display JSON Object
We can set JSON object from above to a variable that use to display the localization text.
Now, time to try our script, when we make set_lang = "en", it should be show up the display like this.
And when we make set_lang = "jp", it should be show up the display like this.
The next step, I think we can make above solution become Class to use it easy on our Project.
See ya next time m(_ _)m