I am trying to put together a NextJS project that needs i18n. I found multiple libraries regarding i18n. Do we really need to those ? Though I went through documentations, maintaining an Object at global level and retrieving it based on locale info from NextJS using some kind of logic feel easier. Is there any specific use-case these libraries are trying to solve ? Am I missing something.
Thanks
You are correct! You can totally simply create a global object and retrieve based on the locale
I personally use next-translate simply because of:
Speed (SEO): I want my bundle size small ( each locale should only get the translations that the combination of page and locale will use )
It includes a function to log missing keys by default
Formaters ( ex.: numbers )
Syntax: I like the "useTranslation" hook and seems easy for future devs to read, also it gets the current locale by itself so just one readable line
Nice syntax for variables and including dynamic components inside the translations
Easy pluralization
But if you don't have many translations and they don't need complex use cases go with the global object and you will be fine, its totally okay