prisma-korea / prisma-nextjs-rsc

Prisma Nextjs and React Server Component template
MIT License
1 stars 0 forks source link

Prisma NextJS RSC

Project is built mainly with nextjs, react server component and prisma.

CI PRs Welcome

Getting started

See Contributing for installation.

Feature

GraphQL api support with codegen is available at https://github.com/prisma-korea/prisma-nextjs-rsc/pulls.

Localization with variable

1. Add text with variable in json

// en.json

"home": {
  "intro": "Hello my name is {{ name }} and {{ age }} years old"
},

2. Get the t from getTranslates


const {t, home} = await getTranslates(lang);

3. Inside the t function, put json text and variables as parameters


// app/[lang]/page.tsx

export default async function Page({
  params: {lang},
}: Props): Promise<ReactElement> {
  const {t, langs, nav, home} = await getTranslates(lang);

  return (
    <Container lang={lang} langs={langs} t={nav}>
      <div className={clsx('flex-1 bg-paper', 'flex flex-col')}>
        <p className={clsx('p-8 text-basic')}>
          {t(home.intro, {name: 'kihun', age: 30})}
        </p>
      </div>
    </Container>
  );
}