You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have some trouble with using typescript with i18n and react.
When I try to use the t function in my code and specifically as a child in tsx, typescript is slow with loading the types that I can use in that function. Can sometimes take up to 5 mins to load. While it is loading typescript itself is so busy getting the types that it won't do anything else. This is really annoying if you have to keep restarting your ts server to make everything work again. My colleagues also tried to do the same thing as I did and had almost no issues (max 3 seconds to load the types). Only difference is that I have a MacBook pro m1-pro while my colleagues are using windows/linux. The translation files that I have a really small (max 30 translations per file).
Anyone know what I am doing wrong?
Here is my setup:
i18n.ts
importi18nfrom"i18next";import{initReactI18next}from"react-i18next";importBackendfrom"i18next-http-backend";importLanguageDetectorfrom"i18next-browser-languagedetector";importcomponentsENGBfrom"./languages/en_GB/components.json";importgeneralENGBfrom"./languages/en_GB/general.json";importcomponentsNLNLfrom"./languages/nl_NL/components.json";importgeneralNLNLfrom"./languages/nl_NL/general.json";importlayoutsNLNLfrom"./languages/nl_NL/layouts.json";importlayoutsENGBfrom"./languages/en_GB/layouts.json";importdecisionToolNLNLfrom"./languages/nl_NL/decisionTool.json";importdecisionToolENGBfrom"./languages/en_GB/decisionTool.json";exportconstdefaultNS="general";exportconstresources={en_GB: {components: componentsENGB,general: generalENGB,layouts: layoutsENGB,decisionTool: decisionToolENGB,},nl_NL: {components: componentsNLNL,decisionTool: decisionToolNLNL,general: generalNLNL,layouts: layoutsNLNL,},}asconst;exportconsti18nInit=i18n.use(Backend).use(LanguageDetector).use(initReactI18next).init({fallbackLng: "en_GB",// TODO: debug should only be true on developmentdebug: true,interpolation: {escapeValue: false,},ns: ["components","general","layouts","decisionTool"],
defaultNS,
resources,});exportdefaulti18n;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I have some trouble with using typescript with i18n and react.
When I try to use the
t
function in my code and specifically as a child in tsx, typescript is slow with loading the types that I can use in that function. Can sometimes take up to 5 mins to load. While it is loading typescript itself is so busy getting the types that it won't do anything else. This is really annoying if you have to keep restarting your ts server to make everything work again. My colleagues also tried to do the same thing as I did and had almost no issues (max 3 seconds to load the types). Only difference is that I have a MacBook pro m1-pro while my colleagues are using windows/linux. The translation files that I have a really small (max 30 translations per file).Anyone know what I am doing wrong?
Here is my setup:
i18n.ts
i18next.d.ts
What it looks like when it is loading
Beta Was this translation helpful? Give feedback.
All reactions