Fork me on GitHub

2 Aug 2011

Avoiding accidental i18n in Grails

We’re developing an app that’s exclusively for a UK audience so i18n really isn’t an issue for us. However recently we got bitten by some i18n creeping in where we didn’t want it. Specifically, when using Grails’ g:dateFormat tag the default behaviour is to format the date according to the Locale specified in the user’s Accept-Language header. Even though we are explicitly specifying a format pattern for the date Java is aware of localized day names for some languages so the output can vary. The result is that on a page full of English text there suddenly appears a Spanish or Swedish day name. What makes things worse is that as we use server-side content caching and a CDN if a user with a non-English Accept-Language header is the first to see a particular page or bit of dynamically retrieved content then the cache is primed and until it expires everyone will see the non-English day name text.
The solution in a Grails app is as simple as replacing Spring’s standard localeResolver bean with an instance of FixedLocaleResolver. Just add the following to grails-app/conf/spring/resources.groovy:
localResolver(org.springframework.web.servlet.i18n.FixedLocaleResolver, Locale.UK)
This changes the way Spring works out the request locale and any locale-aware tags should just fall into place.

16 comments:

Shin Tai said...

Same with formatNumber and where type is currency.

I came across that when my system settings were English (US) which got passed down by Firefox into the headers.

Bella Tran said...

Thanks for publishing this blog
descargar mobogenie | baixar facebook | baixar mobogenie | descargar facebook | facebook descargar | descargar mobogenie | whatsapp descargar and whatsapp gratis | mobogenie descargar

aliamay said...

iPl cricket live and all the updates of cricket.. Ipl 2017 will be scheduled all the news and updates of this season. Get all the news and updates of live cricket on just a single click.

saad said...


Veterans day images
I was searching for something extremly good and I found this one. This really worked for me

Gaming Lover said...

WELL SAYS BUT NOW











Merry Christmas & Happy New Year
Happy New Year Quotes 2019
Merry Christmas & Happy New Year 2019
Happy New Year Messages Poetry 2019
Happy New Year Resolution 2019
Happy New Year Resolutions 2019
Happy New Year Gift Ideas 2019
Happy New Year Wallpapers 2019

Check Also Today Live Match
Today Live Match Streaming
Today Live Match Prediction
World Cup Live Streaming

nandhu said...


snaptube install
snaptube download app
snaptube online
snaptube free download
Considering that SnapTube and TubeMate are designed to do the same thing, the speed at which they download videos is quite important.

seocom said...


___________________________

شركة عزل خزانات بالمدينة المنورة
عند حدوث التسريب لداخل الخزانات أو لخارجها يحدث تلوث المياه ويتم نقل الفطريات و البكتيريا التي تسبب الأمراض و قد تتسرب مياة الآبار والمياه الجوفية إلى داخل الخزانات فى هذة الحالة نقوم بتبطين جدران الخزان لنتمكن من الحفاظ على صحة الأسرة اتصل بنا فى الحال نقدم أفضل خدمة لعزل الخزانات شركة عزل خزانات بالمدينة المنورة لأنها تعد رائدة شركات العزل تعمل فى هذا المجال وخبرتها المميزة جعلتنا فى المقدمة دائما نمتلك أجود خامات عزل مستوردة من الخارج واحدث معدات و نؤكد على ضرورة المحافظة على مياة الخزانات للوقاية من الإصابة بالأمراض والديدان ولدينا أكفأ العمالة الذين تم تدريبهم على يد خبراء متخصصين.

Dale Morris said...

Microsoft Edge Phone Number
Mozilla firefox Customer Service Telephone Number
Outlook Customer Service Phone Number
Sbcglobal Email Support Phone Number

meldaresearch said...

Our custom term paper writing services and custom research paper services are meant to relieve students off stress they go through as they carry out their academic tasks and also enable them to excel in all their custom research paper writing service and research paper services.

Moonlight Bedding said...

Nice and really informative i really appreciate your effort. Thanks for sharing Quilts

akshayavengala said...


appvn ios
appvn app
minecraft appvn
appvn 2019
Appvn Android is one of the best websites online to download APK apps or files

Cricky said...

Thanks for sharing this .. Please check out these links that is related to the psl 2020 schedule, updates, news and more.
Here you can find the latest updates and the updated schedule, news, fixtures, and the other teams and squad information. Pakistan super league is the biggest event that will be happening in february 2020 in pakistan. Sportszilla provides you the latest information about the psl 2020 teams squad the captains names, and the other points tables and the other players category list.
Psl schedule 2020 pdf
Psl 2020 schedule pdf
Psl schedule 2020
Psl 2020 schedule
Psl 2020 live streaming
Psl live streaming 2020
Crichd live
psl schedule 2020 venue
psl schedule 2020 squad
psl schedule 2020 time table
psl schedule 2020 download

sandeepaleti36 said...


Download Facetime for PC
for latest news and updates check our website.

Unknown said...

Check out T20 World Cup Schedule 2020 live matches, scores and much more to stay updated about upcoming cricket events.

sammer mark said...

WOW! Nice written by author If you tried everything and you are unable to take out your HP printer form error state then contact experts. A team of certified experts will help you to fix your HP Printer Wirelrss Setup problem. After having the guidance of experts, you will be able to take out printouts by your HP printer.

عبد الله محمد عبدالله said...


شركة تنظيف مكيفات بالرياض
شركة تنظيف شقق بالرياض