|
| 1 | +# Changelog |
| 2 | + |
| 3 | +All notable changes to this project will be documented in this file. |
| 4 | + |
| 5 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
| 6 | +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 | + |
| 8 | +## [2.0.0] - 2025-11-20 |
| 9 | + |
| 10 | +### 🚨 Breaking Changes |
| 11 | + |
| 12 | +#### Removed Hooks |
| 13 | +- **Removed `useTranslationWithInterpolation` hook** - Functionality merged into `useTranslation` |
| 14 | +- **Removed `useTranslationInjection` hook** - Functionality merged into `useTranslation` |
| 15 | + |
| 16 | +#### `useTranslation` API Changes |
| 17 | +The `useTranslation` hook has been completely refactored with a new API: |
| 18 | + |
| 19 | +**Before (v1.0.0):** |
| 20 | +```typescript |
| 21 | +const t = useTranslation<typeof en>(en); |
| 22 | +const welcome = t.common.welcome; // Proxy-based access |
| 23 | +``` |
| 24 | + |
| 25 | +**After (v2.0.0):** |
| 26 | +```typescript |
| 27 | +const { t } = useTranslation<typeof en>(); |
| 28 | +const welcome = t('common.welcome'); // Function-based access |
| 29 | +``` |
| 30 | + |
| 31 | +**Migration Guide:** |
| 32 | +- Remove the translation object parameter from `useTranslation` |
| 33 | +- Change from property access (`t.common.welcome`) to function calls (`t('common.welcome')`) |
| 34 | +- The hook now returns an object with a `t` function instead of a proxy object |
| 35 | +- Variable injection and component interpolation are now handled through the same `t` function |
| 36 | + |
| 37 | +### ✨ Added |
| 38 | + |
| 39 | +- **`createTranslation` utility** - New utility function for creating type-safe translation functions outside of React components |
| 40 | +- **Enhanced type safety** - Improved TypeScript types with `Path`, `PathValue`, `TranslateFunction`, and `ComponentMap` |
| 41 | +- **Unified API** - Single `t` function now handles both variable injection and component interpolation |
| 42 | +- **React component support** - Built-in support for embedding React components within translations using the `Trans` component |
| 43 | + |
| 44 | +### 🔄 Changed |
| 45 | + |
| 46 | +- **Simplified `useTranslation` hook** - Reduced from 65 lines to 36 lines, improved maintainability |
| 47 | +- **Streamlined exports** - Cleaner export structure in `index.ts` |
| 48 | +- **Enhanced type definitions** - Expanded `types.ts` with comprehensive type utilities for better type safety |
| 49 | + |
| 50 | +### 📝 Documentation |
| 51 | + |
| 52 | +- Updated README.md with new API examples and usage patterns |
| 53 | +- Added comprehensive examples for type-safe translations |
| 54 | +- Clarified variable injection and component interpolation sections |
| 55 | + |
| 56 | +## [1.0.0] - Previous Release |
| 57 | + |
| 58 | +Initial stable release with: |
| 59 | +- Basic translation hooks |
| 60 | +- Language switching functionality |
| 61 | +- Translation validation and sync tools |
| 62 | +- React and React Native support |
| 63 | + |
0 commit comments