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

Typescript issue when 2 arguments on "t" function with JSON files #420

Open
harkor opened this issue Aug 13, 2024 · 0 comments
Open

Typescript issue when 2 arguments on "t" function with JSON files #420

harkor opened this issue Aug 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@harkor
Copy link

harkor commented Aug 13, 2024

Hello,

We need to use translations in JSON and we have a typescript issue when we have second arguments in t()

Example

t('lastUpdate', {updatedAt: '2021-10-01'}
{
  "lastUpdate": "Last update on {updatedAt}"
}

The error is : TS2554: Expected 1 arguments, but got 2

image

Reproduction

https://github.com/harkor/next-internation-json/tree/main

This reproduction is for client, but same thing with server

import {getI18n} from "@/locales/server";
....
const t = await getI18n();
...
{t('lastUpdate', {updatedAt: '2021-10-01'})}

About

  • next-international version : 1.2.4
  • Next.js version: 14.2.5

Temporary fix

We found a quick fix for special translations with arguments but not the ideal. It's time consume for developers

Fix

Full code

@harkor harkor added the bug Something isn't working label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant