Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix build in nextjs example #2152

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Comment on lines 1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the quote format consistent here and in a few other places below. Some imports use ", some '

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, it should be covered by prettier, why it doesn't


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
Loading