Create a Quetzal Project
First, sign up for Quetzal here. You will then be prompted to create a New Quetzal Project.Quetzal is currently free to use for one language
Install Quetzal
Once your project is created, install our npm package to set up your Node.js project with Quetzal.npm install --save @quetzallabs/i18n
Don’t see an option that works for you? Contact
Us if you are unsure of how to set up Quetzal
with your stack
- Makes a change to your
.env
file so you can add your Quetzal API Key - Adds a template
quetzal.config.json
file for you to edit - Adds our locale detector (
i18n.ts
) in your project root which detect’s the user’s locale for use withnext-intl
- Adds a “prebuild” script to your
package.json
so that we can get all your strings before a build and either get the existing translations or translate new strings.
Next-Intl Setup
Quetzal is built on next-intl for Next.js apps and use-intl for React apps. As such, you must update your app to use theNextIntlClientProvider
or IntlProvider
.
For Next projects, you also must include the createNextIntlPlugin
in your next config file. This process is documented by next-intl.
Optional: Install VSCode/Cursor Extension
To dramatically speed up integration throughout your app, install the Quetzal VSCode ExtensionContinue setting up your project
As mentioned above, you should do the following before continuing:- Update your
.env
file with yourQUETZAL_API_KEY
found in the dashboard from the previous step. (If you used the setup script, this will already be added for you!) - Modify the
quetzal.config.json
specifying which folders to scrape fort
-wrapped strings. - Update
next.config.js
ornext.config.mjs
to add thenext-intl
plugin to your project:
next.config.js
next.config.mjs
- Add the
next-intl
provider to yourlayout.tsx
, like so:
Usage
Now you can use thet
function from either the hook or the awaitable function like so:
Async/Server Components
t
function here.
Wrapping Strings for Translation
To find the strings to translate, you can use our VSCode Extension to find all of your user-facing strings. This extension was installed as a part of the setup script. To use it:- Open VSCode
- Press Cmd+Shift+P
- Type “Quetzal” and find “Quetzal: Scan for user-facing strings”
- Select filetypes and folders to scan for strings
- Now you can see every file that has user-facing strings and easily wrap them appropriately
Running translations
To manually submit strings for translation, runnpm run prebuild
. This will scrape all of the strings you wrapped in the previous step and send them to us for translation. This will also run when you run npm run build
. You can see the status of these translations on the Quetzal dashboard. For a few strings, it should only take a second. For many hundreds or thousands of strings, it may take a few minutes.
And now you’re done! Strings will be grabbed and translated when production builds are made going forward.