Localization
Installation
How to install the useTranslation hook and its dependencies
Installation
Install the hook using the shadcn CLI:
npx shadcn@latest add @dr-ui/i18nDependencies
The hook depends on the following packages, which will be installed automatically:
{
"dependencies": [
"i18next",
"react-i18next",
"i18next-cli"
],
}Package.json Script
Add the following script to your package.json to extract translation keys:
{
"scripts": {
"i18n:extract": "i18next-cli extract --config ./src/lib/i18n/i18next.config.ts && npm run lint:fix"
}
}The script will use the i18next.config.ts configuration file that comes with the hook to automatically extract translation keys from your source code and update the locale files.