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

When using Next.js dynamic routing, it is not possible to extract text into Po files. #2183

Open
2 tasks done
Yidoon opened this issue Feb 13, 2025 · 1 comment
Open
2 tasks done
Labels

Comments

@Yidoon
Copy link

Yidoon commented Feb 13, 2025

Description

In my Next.js project, I used dynamic routing [...params], and I customized the output directory for Lingui, finally I discovered that [...params] appeared in the directory. However, there was no content inside; it should have contained a "hello world" message.

The official demo can also reproduce it. 👉repo

Verifications

  • I've checked the docs and this isn't covered there.
  • I've searched existing issues on GitHub.

Reproduction Steps

lingui.config.js
Use {name} to custom the output

const nextConfig = require("./next.config")

/** @type {import('@lingui/conf').LinguiConfig} */
module.exports = {
  locales: nextConfig.i18n.locales,
  pseudoLocale: "pseudo",
  sourceLocale: nextConfig.i18n.defaultLocale,
  fallbackLocales: {
    default: "en",
  },
  catalogs: [
    {
      path: "src/locales/{name}/{locale}/messages",
      include: ["src/pages/{name}"],
    },
  ],
}

pages/[...params]/index.tsx
add 'Hello world'

import { Trans } from "@lingui/react/macro"

export default function Home() {
  return <Trans>Hello World</Trans>
}

locales/[...params]/cs/message.po
But 'hello world' did not appear

msgid ""
msgstr ""
"POT-Creation-Date: 2025-02-13 20:31+0800\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: cs\n"

Expected Behavior

"hello word" should appear in the po file

Macro Support

Babel with babel-macro-plugin

Lingui Version

5.0.0-next.2

Babel Version

5.0.0-next.2

Framework

Next.js

@Yidoon Yidoon added the bug label Feb 13, 2025
@timofei-iatsenko
Copy link
Collaborator

Sounds like a bug, probably some issue with folder matching when there is [..] symbols.

The PR with a fix is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants