๐ Internationalization โ
The KitchenAsty storefront supports multiple languages using i18next with React.
๐บ๏ธ Supported Languages โ
| Code | Language |
|---|---|
en | ๐ฌ๐ง English |
es | ๐ช๐ธ Spanish |
fr | ๐ซ๐ท French |
de | ๐ฉ๐ช German |
it | ๐ฎ๐น Italian |
pt | ๐ต๐น Portuguese |
โ๏ธ How It Works โ
- ๐ Translations are stored as JSON files in
packages/storefront/src/i18n/locales/ - ๐พ The selected language is persisted to
localStorage - ๐ท๏ธ The
<html lang>attribute updates automatically on language change - ๐ Fallback language is English
๐ Translation Keys โ
Translations are organized by domain:
| Namespace | Content |
|---|---|
common | ๐ Shared strings โ loading, errors, buttons |
nav | ๐งญ Navigation items |
home | ๐ Homepage hero and features |
auth | ๐ Login and registration forms |
menu | ๐ฝ๏ธ Menu browsing and search |
cart | ๐ Shopping cart |
checkout | ๐ณ Checkout flow |
orders | ๐ฆ Order history and status |
reservations | ๐ช Table booking |
reviews | โญ Review submission and display |
โ Adding a New Language โ
- Create a new locale file:
bash
cp packages/storefront/src/i18n/locales/en.json packages/storefront/src/i18n/locales/ja.jsonTranslate all keys in the new file.
Register the language in
packages/storefront/src/i18n/index.ts:
typescript
import ja from './locales/ja.json';
// Add to resources
resources: {
// ... existing languages
ja: { translation: ja },
}- Add the language option to the storefront language picker component.
๐ค Translation Script โ
For bulk translation, you can use automated tools:
bash
# Example: translate en.json to Japanese using a translation API
npx tsx scripts/translate.ts --from en --to ja๐งฉ Using Translations in Components โ
tsx
import { useTranslation } from 'react-i18next';
function MenuPage() {
const { t } = useTranslation();
return <h1>{t('menu.title')}</h1>;
}TIP
The admin dashboard currently uses English only. Contributions for admin i18n are welcome.