This is an example project showcasing a multilingual AI Chatbot using gt-next
.
This project was using the Vercel AI Chatbot Template.
Change your browser language to see the translations in action.
One-click deploy to Vercel:
Everything works out of the box!
See the docs for more information on how to use gt-next
with Next.js.
To clone this example and see it in action yourself, follow the following steps:
- Run
git clone https://github.com/General-Translation/gt-libraries.git
cd gt-libraries/examples/next-chatbot
npm install
-
(Optional) Create a
.local.env
file and populate it withGT_PROJECT_ID
andGT_API_KEY
, obtainable via the GT Dashboard here- This example comes with translations for French, Spanish, and Chinese out of the box, but if you want to experiment with other locales or modify some content, you'll need to add your own API keys.
-
Run
npm run dev
Here is a list of steps done to reach this repo state:
npx create-next-app@latest
npm install gt-next gt-next-cli
npx gt-next-cli setup
- Add locales to the
next.config.ts
file:
export default withGTConfig(nextConfig, {
defaultLocale: 'en-US',
locales: ['en-US', 'fr', 'es', 'zh'],
});
- Wrap strings with
t
:
const t = useGT();
t('Hello, world!');
- (optional) Create a
.local.env
file and populate it withGT_PROJECT_ID
andGT_API_KEY
- These environment variables are needed for local translations during development. The
GT_API_KEY
should be a development API key. A separate production API Key is needed for subsequent steps when deploying to production.
- These environment variables are needed for local translations during development. The
npm run dev
To deploy this app to production:
- Add
GT_PROJECT_ID
andGT_API_KEY
to your.env.local
file- The
GT_API_KEY
should be a production API key.
- The
npx gt-next-cli translate --locales es fr zh
- Deploy to Vercel / Render / etc..