Uniswap / interface

🦄 Open source interfaces for the Uniswap protocol
https://app.uniswap.org
GNU General Public License v3.0
4.81k stars 4.86k forks source link

unable to resolve translations when start in local #7723

Open nanne007 opened 1 month ago

nanne007 commented 1 month ago

I followed the guide here https://github.com/Uniswap/interface/tree/main/apps/web to start web interface. I got errors when running yarn start in apps/web folder.

Failed to compile.

Module not found: Error: Can't resolve './i18n/locales/translations' in '/Users/caojiafeng/projects/Uniswap/interface/apps/web/src'
ERROR in ./src/i18n.tsx 20:11-65
Module not found: Error: Can't resolve './i18n/locales/translations' in '/Users/caojiafeng/projects/Uniswap/interface/apps/web/src'

It has something to do with translation. How to resolve the issue?

JayJay1024 commented 3 weeks ago

I think there might be a conflict between server-side rendering and client-side rendering. I temporarily solved this issue by directly returning enUsLocale

--- a/apps/web/src/i18n.tsx
+++ b/apps/web/src/i18n.tsx
@@ -18,10 +18,11 @@ i18n
       if (!language.includes('-')) {
         return
       }
-      if (language === 'en-US') {
-        return enUsLocale
-      }
-      return import(`./i18n/locales/translations/${language}.json`)
+      return enUsLocale
+      // if (language === 'en-US') {
+      //   return enUsLocale
+      // }
+      // return import(`./i18n/locales/translations/${language}.json`)
     })
   )
   .on('failedLoading', (language, namespace, msg) => {