All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Removed
useTranslationWithInterpolationhook - Functionality merged intouseTranslation - Removed
useTranslationInjectionhook - Functionality merged intouseTranslation
The useTranslation hook has been completely refactored with a new API:
Before (v1.0.0):
const t = useTranslation<typeof en>(en);
const welcome = t.common.welcome; // Proxy-based accessAfter (v2.0.0):
const { t } = useTranslation<typeof en>();
const welcome = t('common.welcome'); // Function-based accessMigration Guide:
- Remove the translation object parameter from
useTranslation - Change from property access (
t.common.welcome) to function calls (t('common.welcome')) - The hook now returns an object with a
tfunction instead of a proxy object - Variable injection and component interpolation are now handled through the same
tfunction
createTranslationutility - New utility function for creating type-safe translation functions outside of React components- Enhanced type safety - Improved TypeScript types with
Path,PathValue,TranslateFunction, andComponentMap - Unified API - Single
tfunction now handles both variable injection and component interpolation - React component support - Built-in support for embedding React components within translations using the
Transcomponent
- Simplified
useTranslationhook - Reduced from 65 lines to 36 lines, improved maintainability - Streamlined exports - Cleaner export structure in
index.ts - Enhanced type definitions - Expanded
types.tswith comprehensive type utilities for better type safety
- Updated README.md with new API examples and usage patterns
- Added comprehensive examples for type-safe translations
- Clarified variable injection and component interpolation sections
Initial stable release with:
- Basic translation hooks
- Language switching functionality
- Translation validation and sync tools
- React and React Native support