I am currently in the process of developing a web application using Next.js that will cater to users who speak my native language and English. I have a specific approach in mind:
- First, I plan to create a folder: /pages/en-us
pages/
|--(all app pages)
|--en-us/
|--(all app pages like above)
- Next, I intend to wrap the entire application with a LanguageContext. Additionally, I will implement a middleware function to detect the visitor's country based on their IP address upon loading the page. If the visitor is from a foreign country or if the current language is set to English, they will be redirected to the
/en-us
path.
For instance,/login
would redirect to/en-us/login
.
While I am aware of frameworks such as i18next for multi-language support, I believe my web application only requires support for two languages and may not necessitate the use of such frameworks.
Do you think my approach is suitable? If not, I welcome any advice or recommendations.