Split initI18n() into separate server/client initialization paths inspired by remix-i18next's architecture: - initI18nServer(lng): no LanguageDetector, per-request language from Accept-Language header - initI18nClient(): LanguageDetector reads <html lang> first to match server, then localStorage and navigator - detectLanguage(request): parses Accept-Language for best match Fixes rehydration errors caused by v26 removing initImmediate option (replaced with initAsync) and LanguageDetector running on the server where browser APIs don't exist. Also makes <html lang> dynamic instead of hardcoded "en". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
16 lines
318 B
JSON
16 lines
318 B
JSON
{
|
|
"name": "@trails-cool/i18n",
|
|
"version": "0.0.1",
|
|
"type": "module",
|
|
"exports": {
|
|
".": "./src/index.ts",
|
|
"./locales/*": "./src/locales/*"
|
|
},
|
|
"main": "./src/index.ts",
|
|
"types": "./src/index.ts",
|
|
"peerDependencies": {
|
|
"react": ">=18",
|
|
"i18next": ">=26",
|
|
"react-i18next": ">=17"
|
|
}
|
|
}
|