Skip to content

Commit

Permalink
feat: attempt for error replication
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 committed Oct 18, 2023
1 parent 06939d8 commit fa6be45
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 103 deletions.
143 changes: 75 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
"dependencies": {
"@tolgee/format-icu": "5.13.1",
"@tolgee/react": "5.13.1",
"next": "13.4.7",
"next": "^13.5.5",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "20.8.6",
"@types/react": "18.0.28",
"eslint": "8.35.0",
"eslint-config-next": "13.2.3",
Expand Down
15 changes: 15 additions & 0 deletions src/components/tolgee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DevTools, Tolgee } from '@tolgee/react'
import { FormatIcu } from '@tolgee/format-icu'
import en from '../../public/i18n/en.json'

const apiKey = process.env.NEXT_PUBLIC_TOLGEE_API_KEY;
const apiUrl = process.env.NEXT_PUBLIC_TOLGEE_API_URL;

export const tolgee = Tolgee().use(DevTools()).use(FormatIcu()).init({
defaultLanguage: 'en',
apiKey: apiKey,
apiUrl: apiUrl,
staticData: {
en
}
})
18 changes: 18 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TolgeeProvider, useTolgeeSSR } from "@tolgee/react";
import { useRouter } from "next/router";
import { AppProps } from "next/app";

import { tolgee } from "../components/tolgee";

const App = ({ Component, pageProps }: AppProps) => {
const router = useRouter();
const ssrTolgee = useTolgeeSSR(tolgee, router.locale);

return (
<TolgeeProvider tolgee={ssrTolgee}>
<Component {...pageProps} />
</TolgeeProvider>
);
};

export default (App);
21 changes: 4 additions & 17 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
import type { GetStaticProps, NextPage } from 'next';
import { getServerLocales, TolgeeNextProvider } from '../tolgeeNext';
import { Todos } from '../views/Todos';
import type { NextPage } from "next";
import { Todos } from "../views/Todos";

export const getStaticProps: GetStaticProps = async (context) => {
return {
props: {
locales: await getServerLocales(context.locale),
},
};
};

const Home: NextPage<{ locales: any }> = ({ locales }) => {
return (
<TolgeeNextProvider locales={locales}>
<Todos />
</TolgeeNextProvider>
);
const Home: NextPage = () => {
return <Todos />;
};

export default Home;
21 changes: 4 additions & 17 deletions src/pages/translation-methods.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
import type { GetStaticProps, NextPage } from 'next';
import { getServerLocales, TolgeeNextProvider } from '../tolgeeNext';
import { TranslationMethods } from '../views/TranslationMethods';
import type { NextPage } from "next";
import { TranslationMethods } from "../views/TranslationMethods";

export const getStaticProps: GetStaticProps = async (context) => {
return {
props: {
locales: await getServerLocales(context.locale, ['', 'namespaced']),
},
};
};

const Home: NextPage<{ locales: any }> = ({ locales }) => {
return (
<TolgeeNextProvider locales={locales}>
<TranslationMethods />
</TolgeeNextProvider>
);
const Home: NextPage = () => {
return <TranslationMethods />;
};

export default Home;

0 comments on commit fa6be45

Please sign in to comment.