0.1.23 • Published 9 months ago

@quetzallabs/i18n-next v0.1.23

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Welcome to Quetzal!

This package contains all the utilities you need to get started using Quetzal.

To install: npm install --save @quetzallabs/i18n

Once installed, run npx quetzal-setup

Read more about how to use this package at: https://quetzal.mintlify.app/getting-started

This package relies on the next-intl provider to put translations into your app: https://www.npmjs.com/package/next-intl

Be sure to include this provider within your next application, and to put the next-intl plugin in your next config file

The t function

Text in your application is translated by wrapping it in a t function. This function is built on the next-intl t function: https://next-intl-docs.vercel.app/docs/usage/messages

For components:

import { useI18n } from "@quetzallabs/i18n-next"; const { t } = useI18n();

For server-side:

import { getI18nUtils } from "@quetzallabs/i18n-next"; const { t } = await getI18nUtils();

Example usage:

t("This text will be translated to multiple locales by Quetzal")

Once your application has some of its text in t functions, you can run npx quetzal-process-translations. This command will send new text to be translated and fetch text that has been translated already.

This command should be executed before every build to ensure up-to-date translations are included.