Giriş
Açıklaması şöyle
Cookies are also another option that has an implementation available. They are stored on the user’s machine and as long as browser cookies aren’t cleared by the user, once resolved the resolved locale data will last even between sessions.
Açıklaması şöyle. LocaleChangeInterceptor yazısına bakabilirsiniz
Note: For SessionLocaleResolver and CookieLocaleResolver we need to have an interceptor to get the parameter sent from the user for the preferred language and store it in session or cookie. Thanks to spring this has been done already don and you can use LocaleChangeInterceptor and just pass the name of the property to set the locale.
constructor
Şöyle yaparız
@Bean
public LocaleResolver localeResolver() {
CookieLocaleResolver lr = new CookieLocaleResolver();
lr.setDefaultLocale(Locale.US);
return lr;
}
setDefaultLocale metodu
Şöyle yaparız.
Şöyle yaparız.
@Bean
public LocaleResolver localeResolver() {
final CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
cookieLocaleResolver.setDefaultLocale(Locale.ENGLISH);
return cookieLocaleResolver;
}
Hiç yorum yok:
Yorum Gönder