Skip to content

Commit

Permalink
feat: Add setup file
Browse files Browse the repository at this point in the history
  • Loading branch information
codemod[bot] committed Dec 13, 2024
1 parent 6b1c747 commit 314b5af
Show file tree
Hide file tree
Showing 18 changed files with 331 additions and 11 deletions.
5 changes: 4 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"eslint-config-next": "^13.2.1",
"gray-matter": "^4.0.3",
"handlebars": "^4.7.7",
"i18next": "^24.1.0",
"ical.js": "^1.4.0",
"ics": "^2.37.0",
"jose": "^4.13.1",
Expand Down Expand Up @@ -124,6 +125,7 @@
"react-easy-crop": "^3.5.2",
"react-hook-form": "^7.43.3",
"react-hot-toast": "^2.3.0",
"react-i18next": "^15.2.0",
"react-intl": "^5.25.1",
"react-live-chat-loader": "^2.8.1",
"react-multi-email": "^0.5.3",
Expand Down Expand Up @@ -198,5 +200,6 @@
"budgetPercentIncreaseRed": 20,
"minimumChangeThreshold": 500,
"showDetails": true
}
},
"i18next-browser-languagedetector": "^8.0.2"
}
2 changes: 2 additions & 0 deletions apps/web/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { I18nextProvider } from "react-i18next";
import { i18n } from "./i18n";
import type { IncomingMessage } from "http";
import type { AppContextType } from "next/dist/shared/lib/utils";
import React, { useEffect } from "react";
Expand Down
47 changes: 47 additions & 0 deletions apps/web/pages/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { Resource } from "i18next";
import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { initReactI18next } from "react-i18next";

void i18n
.use({
type: "backend",
read(
language: string,
namespace: string,
callback: (errorValue: unknown, translations: null | Resource) => void,
) {
import(`./${namespace}/locales/${language}.json`)
.then((resources) => {
callback(null, resources as unknown as Resource);
})
.catch((error) => {
callback(error, null);
});
},
})
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: "en",
debug: true,

interpolation: {
escapeValue: false,
},

// react i18next special options (optional)
// override if needed - omit if ok with defaults
/*
react: {
bindI18n: 'languageChanged',
bindI18nStore: '',
transEmptyNodeValue: '',
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],
useSuspense: true,
}
*/
});

export { i18n };
7 changes: 5 additions & 2 deletions example-apps/credential-sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
"dependencies": {
"@calcom/atoms": "*",
"@prisma/client": "5.4.2",
"i18next": "^24.1.0",
"next": "14.0.4",
"prisma": "^5.7.1",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"react-i18next": "^15.2.0"
},
"devDependencies": {
"@types/node": "^20.3.1",
Expand All @@ -27,5 +29,6 @@
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^4.9.4"
}
},
"i18next-browser-languagedetector": "^8.0.2"
}
47 changes: 47 additions & 0 deletions example-apps/credential-sync/pages/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { Resource } from "i18next";
import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { initReactI18next } from "react-i18next";

void i18n
.use({
type: "backend",
read(
language: string,
namespace: string,
callback: (errorValue: unknown, translations: null | Resource) => void,
) {
import(`./${namespace}/locales/${language}.json`)
.then((resources) => {
callback(null, resources as unknown as Resource);
})
.catch((error) => {
callback(error, null);
});
},
})
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: "en",
debug: true,

interpolation: {
escapeValue: false,
},

// react i18next special options (optional)
// override if needed - omit if ok with defaults
/*
react: {
bindI18n: 'languageChanged',
bindI18nStore: '',
transEmptyNodeValue: '',
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],
useSuspense: true,
}
*/
});

export { i18n };
6 changes: 5 additions & 1 deletion example-apps/credential-sync/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { I18nextProvider } from "react-i18next";
import { i18n } from "./i18n";
import { useRouter, useSearchParams, usePathname } from "next/navigation";
import { useEffect, useState } from "react";

Expand Down Expand Up @@ -43,7 +45,8 @@ export default function Index() {
}

return (
<div>
<I18nextProvider i18n={i18n}>
<div>
<h1>Welcome to Credential Sync Playground</h1>
<p>
You are managing credentials for cal.com <strong>userId={userId}</strong> for{" "}
Expand All @@ -53,5 +56,6 @@ export default function Index() {
<button onClick={() => updateToken()}>Give a valid token to Cal.com</button>
<div>{data}</div>
</div>
</I18nextProvider>
);
}
7 changes: 5 additions & 2 deletions packages/app-store-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
],
"dependencies": {
"@calcom/lib": "*",
"i18next": "^24.1.0",
"ink": "^3.2.0",
"ink-select-input": "^4.2.1",
"ink-text-input": "^4.0.3",
"meow": "^9.0.0",
"react": "^18.2.0"
"react": "^18.2.0",
"react-i18next": "^15.2.0"
},
"devDependencies": {
"@types/react": "18.0.26",
Expand All @@ -32,5 +34,6 @@
"eslint-plugin-react-hooks": "^4.6.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
}
},
"i18next-browser-languagedetector": "^8.0.2"
}
2 changes: 2 additions & 0 deletions packages/app-store-cli/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { I18nextProvider } from "react-i18next";
import { i18n } from "./i18n";
import React, { FC } from "react";
import { SupportedCommands } from "src/types";

Expand Down
47 changes: 47 additions & 0 deletions packages/app-store-cli/src/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { Resource } from "i18next";
import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { initReactI18next } from "react-i18next";

void i18n
.use({
type: "backend",
read(
language: string,
namespace: string,
callback: (errorValue: unknown, translations: null | Resource) => void,
) {
import(`./${namespace}/locales/${language}.json`)
.then((resources) => {
callback(null, resources as unknown as Resource);
})
.catch((error) => {
callback(error, null);
});
},
})
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: "en",
debug: true,

interpolation: {
escapeValue: false,
},

// react i18next special options (optional)
// override if needed - omit if ok with defaults
/*
react: {
bindI18n: 'languageChanged',
bindI18nStore: '',
transEmptyNodeValue: '',
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],
useSuspense: true,
}
*/
});

export { i18n };
5 changes: 4 additions & 1 deletion packages/emails/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
"dependencies": {
"@calcom/dayjs": "*",
"@calcom/lib": "*",
"i18next": "^24.1.0",
"next-i18next": "^13.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^15.2.0",
"rrule": "^2.7.1"
},
"devDependencies": {
"@calcom/tsconfig": "*",
"@calcom/types": "*"
}
},
"i18next-browser-languagedetector": "^8.0.2"
}
2 changes: 2 additions & 0 deletions packages/emails/src/components/BaseEmailHtml.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { I18nextProvider } from "react-i18next";
import { i18n } from "./i18n";
/* eslint-disable @next/next/no-head-element */
import BaseTable from "./BaseTable";
import EmailBodyLogo from "./EmailBodyLogo";
Expand Down
47 changes: 47 additions & 0 deletions packages/emails/src/components/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { Resource } from "i18next";
import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { initReactI18next } from "react-i18next";

void i18n
.use({
type: "backend",
read(
language: string,
namespace: string,
callback: (errorValue: unknown, translations: null | Resource) => void,
) {
import(`./${namespace}/locales/${language}.json`)
.then((resources) => {
callback(null, resources as unknown as Resource);
})
.catch((error) => {
callback(error, null);
});
},
})
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: "en",
debug: true,

interpolation: {
escapeValue: false,
},

// react i18next special options (optional)
// override if needed - omit if ok with defaults
/*
react: {
bindI18n: 'languageChanged',
bindI18nStore: '',
transEmptyNodeValue: '',
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],
useSuspense: true,
}
*/
});

export { i18n };
5 changes: 4 additions & 1 deletion packages/platform/examples/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
"dependencies": {
"@calcom/atoms": "*",
"@prisma/client": "5.4.2",
"i18next": "^24.1.0",
"next": "14.0.4",
"prisma": "^5.7.1",
"react": "^18",
"react-dom": "^18",
"react-i18next": "^15.2.0",
"react-select": "^5.8.0"
},
"devDependencies": {
Expand All @@ -27,5 +29,6 @@
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^4.9.4"
}
},
"i18next-browser-languagedetector": "^8.0.2"
}
6 changes: 5 additions & 1 deletion packages/platform/examples/base/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { I18nextProvider } from "react-i18next";
import { i18n } from "./i18n";
import type { Data } from "@/pages/api/get-managed-users";
import "@/styles/globals.css";
import type { AppProps } from "next/app";
Expand Down Expand Up @@ -75,7 +77,8 @@ export default function App({ Component, pageProps }: AppProps) {
}, [selectedUser]);

return (
<div className={`${poppins.className} text-black`}>
<I18nextProvider i18n={i18n}>
<div className={`${poppins.className} text-black`}>
{options.length > 0 && (
<Select defaultValue={selectedUser} onChange={setSelectedUser} options={options} />
)}
Expand Down Expand Up @@ -122,5 +125,6 @@ export default function App({ Component, pageProps }: AppProps) {
</div>
)}
</div>
</I18nextProvider>
);
}
Loading

0 comments on commit 314b5af

Please sign in to comment.