Open tk1024 opened 3 months ago
like this?
locale === 'ja' ? "": "<br/>"
like this? locale === 'ja' ? "": "
"
I think different.
I have provided the code in codesandbox to make it easier to understand the intent. codesandbox
en.ts
export default {
"hello.world": "Hello {br_en}World",
} as const;
fr.ts
export default {
"hello.world": "Bonjour {br_fr}le monde !",
} as const;
page.tsx
import { getI18n, getScopedI18n } from "../../locales/server";
export default async function Page() {
const t = await getI18n();
const scopedT = await getScopedI18n("hello");
return (
<div>
<p>
{t("hello.world", {
br_en: <br />,
// br_fr: <br />, // TypeError when uncommenting
})}
</p>
</div>
);
}
Due to the varying lengths of text across languages, there are instances where I want to insert line break tags exclusively in a specific language. Here is a sample code illustrating this:
en.ts
ja.ts
In this scenario, when Japanese is set as the default language, attempting to insert params as shown below results in a type error.
Is there a way to reference both English and Japanese translation files and specify params if they are included in either language?