Skip to content

Commit

Permalink
examples: update nextjs example. Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Jan 17, 2025
1 parent 20d8478 commit a032163
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 21 deletions.
15 changes: 13 additions & 2 deletions examples/nextjs-swc/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ const nextConfig: NextConfig = {
as: '*.js'
}
}
}
}
},
},
// turbopack is used for development server only,
// so for build we still need webpack configuration
webpack: (config) => {
config.module.rules.push({
test: /\.po$/,
use: {
loader: '@lingui/loader',
},
})
return config
},
}

export default nextConfig
4 changes: 2 additions & 2 deletions examples/nextjs-swc/src/app/[lang]/app-router-demo/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HomePage } from '../../../components/HomePage'
import { initLingui } from '../../../initLingui'
import { initLingui, PageLangParam } from "../../../initLingui"

export default async function Page(props) {
export default async function Page(props: PageLangParam) {
const lang = (await props.params).lang
initLingui(lang)
return <HomePage />
Expand Down
7 changes: 3 additions & 4 deletions examples/nextjs-swc/src/app/[lang]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import linguiConfig from '../../../lingui.config'
import { allMessages, getI18nInstance } from '../../appRouterI18n'
import { LinguiClientProvider } from '../../components/LinguiClientProvider'
import { initLingui, PageLangParam } from '../../initLingui'
import React from 'react'
import { t } from '@lingui/macro'
import { setI18n } from '@lingui/react/server'
import React, { PropsWithChildren } from "react"
import { t } from '@lingui/core/macro'

export async function generateStaticParams() {
return linguiConfig.locales.map((lang) => ({ lang }))
Expand All @@ -18,7 +17,7 @@ export async function generateMetadata(props: PageLangParam) {
}
}

export default async function RootLayout({ children, params }) {
export default async function RootLayout({ children, params }: PropsWithChildren<PageLangParam>) {
const lang = (await params).lang
initLingui(lang)

Expand Down
6 changes: 4 additions & 2 deletions examples/nextjs-swc/src/app/[lang]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Link from "next/link"

export default function Index() {
return (
<>
This is the homepage of the demo app. This page is not localized. You can
go to the <a href="/app-router-demo">App router demo</a> or the{' '}
<a href="/pages-router-demo">Pages router demo</a>.
go to the <Link href="/app-router-demo">App router demo</Link> or the{' '}
<Link href="/pages-router-demo">Pages router demo</Link>.
</>
)
}
3 changes: 2 additions & 1 deletion examples/nextjs-swc/src/components/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import { useLingui } from '@lingui/react'
import Head from 'next/head'
import { t, Trans } from '@lingui/macro'
import { t } from "@lingui/core/macro"
import { Trans } from "@lingui/react/macro"
import { Switcher } from './Switcher'
import { AboutText } from './AboutText'
import Developers from './Developers'
Expand Down
4 changes: 2 additions & 2 deletions examples/nextjs-swc/src/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ msgstr "Serbian"
msgid "Spanish"
msgstr "Spanish"

#: src/components/HomePage.tsx:22
#: src/app/[lang]/layout.tsx:16
#: src/components/HomePage.tsx:21
msgid "Translation Demo"
msgstr "Translation Demo"

#: src/components/HomePage.tsx:28
#: src/components/HomePage.tsx:29
msgid "Welcome to <0>Next.js!</0>"
msgstr "Welcome to <0>Next.js!</0>"
4 changes: 2 additions & 2 deletions examples/nextjs-swc/src/locales/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ msgstr "Serbio"
msgid "Spanish"
msgstr "Español"

#: src/components/HomePage.tsx:22
#: src/app/[lang]/layout.tsx:16
#: src/components/HomePage.tsx:21
msgid "Translation Demo"
msgstr "Demostración de Traducción"

#: src/components/HomePage.tsx:28
#: src/components/HomePage.tsx:29
msgid "Welcome to <0>Next.js!</0>"
msgstr "Bienvenido a <0>Next.js!</0>"
4 changes: 2 additions & 2 deletions examples/nextjs-swc/src/locales/pseudo.po
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ msgstr ""
msgid "Spanish"
msgstr ""

#: src/components/HomePage.tsx:22
#: src/app/[lang]/layout.tsx:16
#: src/components/HomePage.tsx:21
msgid "Translation Demo"
msgstr ""

#: src/components/HomePage.tsx:28
#: src/components/HomePage.tsx:29
msgid "Welcome to <0>Next.js!</0>"
msgstr ""
4 changes: 2 additions & 2 deletions examples/nextjs-swc/src/locales/sr.po
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ msgstr "Српски"
msgid "Spanish"
msgstr "Шпански"

#: src/components/HomePage.tsx:22
#: src/app/[lang]/layout.tsx:16
#: src/components/HomePage.tsx:21
msgid "Translation Demo"
msgstr "Демо Превод"

#: src/components/HomePage.tsx:28
#: src/components/HomePage.tsx:29
msgid "Welcome to <0>Next.js!</0>"
msgstr "Добродошли у <0>Нект.јс!</0>"
2 changes: 1 addition & 1 deletion examples/remix-vite-babel/app/modules/lingui/lingui.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { i18n, MessageDescriptor } from "@lingui/core";
import { msg } from "@lingui/macro";
import { msg } from "@lingui/core/macro";
import { useFetcher, useFetchers, useMatches, useRouteLoaderData } from "@remix-run/react";
import type config from "./config";
import { ComponentProps } from "react";
Expand Down
4 changes: 3 additions & 1 deletion examples/remix-vite-babel/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { t, Trans } from "@lingui/macro";
import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";

import { json, type MetaFunction } from "@remix-run/node";
import { LocaleSelector } from "~/modules/lingui/lingui";

Expand Down

0 comments on commit a032163

Please sign in to comment.