Files
spring-boot-demo/i18n/output/03-cookie-locale-resolver.txt
Claude 2cbf31e7d5 Add i18n module: MessageSource, LocaleResolver and localized ProblemDetail
English, Marathi and Hindi bundles behind one small web app, with tests that run it on a real
port and write the transcripts (01-11) quoted in the article, plus a jar-metadata capture (12).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Uu7q8vPeREyT4218EJPzz1
2026-09-24 09:54:55 +00:00

21 lines
1.4 KiB
Plaintext

# Letting the user pick a language: ?lang=mr with a cookie resolver, and two ways to get it wrong
--- A. CookieLocaleResolver named localeResolver + LocaleChangeInterceptor (profile 'cookie') ---
no cookie yet, Accept-Language: hi -> status=200 locale=en message=Hello, Asha!
?lang=mr, Accept-Language: hi -> status=200 locale=mr message=नमस्कार, Asha!
Set-Cookie: lang=mr; Path=/; Max-Age=2592000; SameSite=Lax
Cookie: lang=mr, Accept-Language: hi -> status=200 locale=mr message=नमस्कार, Asha!
--- B. the same resolver under the bean name cookieLocaleResolver (profile 'cookiewrongname') ---
Accept-Language: hi -> status=200 locale=hi message=नमस्ते, Asha!
?lang=mr -> status=500 (Tomcat's own HTML error page)
bean 'cookieLocaleResolver' exists: true
bean 'localeResolver' is a: AcceptHeaderLocaleResolver
what the interceptor triggers: UnsupportedOperationException: Cannot change HTTP Accept-Language header - use a different locale resolution strategy
--- C. only the interceptor, Spring Boot's default resolver (profile 'interceptoronly') ---
?lang=mr -> status=500 (Tomcat's own HTML error page)
bean 'localeResolver' is a: AcceptHeaderLocaleResolver
what the interceptor triggers: UnsupportedOperationException: Cannot change HTTP Accept-Language header - use a different locale resolution strategy