Skip to content

๐ŸŒ Internationalization โ€‹

The KitchenAsty storefront supports multiple languages using i18next with React.

๐Ÿ—บ๏ธ Supported Languages โ€‹

CodeLanguage
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:

NamespaceContent
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 โ€‹

  1. Create a new locale file:
bash
cp packages/storefront/src/i18n/locales/en.json packages/storefront/src/i18n/locales/ja.json
  1. Translate all keys in the new file.

  2. 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 },
}
  1. 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.