[{"data":1,"prerenderedAt":326},["ShallowReactive",2],{"Categories":3,"NavIndexCategoriesCountFooter":203,"content-\u002F2010\u002F03\u002F15\u002Fstruts2-i18n-where-application-default-locale-doesn-t-match-app-server-locale\u002F":204},[4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,68,70,71,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202],{"category":5},"System Administration",{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},"Software Development",{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":27},{"category":27},{"category":67},"Drones & RC",{"category":69},"DIY Projects",{"category":67},{"category":72},"Photography",{"category":69},{"category":69},{"category":69},{"category":67},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":67},{"category":69},{"category":69},{"category":67},{"category":67},{"category":72},{"category":72},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":5},{"category":5},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":5},{"category":67},{"category":67},{"category":72},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":72},{"category":67},{"category":138},"3D Printing - Laser Cutting - CNC",{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":5},{"category":138},{"category":27},{"category":27},{"category":138},{"category":138},{"category":72},{"category":158},"Photography,3D Printing - Laser Cutting - CNC",{"category":27},{"category":27},{"category":69},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":67},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":27},{"category":69},{"category":27},{"category":27},{"category":27},{"category":27},{"category":181},"Home Assistant",{"category":181},{"category":72},{"category":27},{"category":27},{"category":72},{"category":138},{"category":5},{"category":72},{"category":72},{"category":138},{"category":27},{"category":181},{"category":181},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},191,{"id":205,"title":206,"body":207,"category":311,"date":312,"description":213,"embedImage":311,"extension":313,"image":311,"intro":311,"meta":314,"navigation":315,"path":316,"seo":317,"series":311,"sitemap":318,"stem":319,"tags":320,"__hash__":325},"content\u002F2010\u002F03\u002F15\u002Fstruts2-i18n-where-application-default-locale-doesn-t-match-app-server-locale.md","Struts2 i18n where application default locale doesn't match app server locale",{"type":208,"value":209,"toc":306},"minimark",[210,214,217,220,230,233,236,243,246,252,260,265,270,273,281,292,295,300,303],[211,212,213],"p",{},"I have a struts2 (2.1.6) based webapp which has two languages - english and norwegian. The default language for the app is norwegian - the application server (glassfish 2.1) is running under the english locale.",[211,215,216],{},"It didn't seem to matter what value I passed in to the request_locale parameter - I always got english.",[211,218,219],{},"There are two language files:",[221,222,223,227],"ul",{},[224,225,226],"li",{},"global_messages.properties (norwegian)",[224,228,229],{},"global_messages_en.properties (english)",[211,231,232],{},"The struts constant struts.custom.i18n.resources was set to \"global_messages\" in struts.xml.",[211,234,235],{},"Googling suggested trying to set struts.locale=no in struts.xml - this may work for other versions - but did nothing under 2.1.6.",[211,237,238,239],{},"Passing in request_locale=no looked for a matching language file - and as it didn't find it - it tried to use the default language ",[240,241,242],"em",{},"based on the locale of the app server",[211,244,245],{},"Up until now I was aware of two options",[247,248,249],"ol",{},[224,250,251],{},"Run the app server under locale=no",[221,253,254,257],{},[224,255,256],{},"This would cause havoc for other english apps on the same webserver.",[224,258,259],{},"This would probably be a good solution for app servers that are dedicated to an app.",[247,261,262],{},[224,263,264],{},"Maintain a copy of global_mesages.properties called global_messages_no.properties",[221,266,267],{},[224,268,269],{},"This is not a good maintenance solution - you have two copies and can miss updates",[211,271,272],{},"The solution was actually pretty simple.",[211,274,275,276,280],{},"Create a global_messages_no.properties that ",[277,278,279],"strong",{},"is empty",".",[211,282,283,284,287,288,291],{},"Then - when you set the request_locale to no it ",[240,285,286],{},"matches"," the empty file. This then does not bother looking at the locale of the app server. However - there are no matching properties ",[240,289,290],{},"within"," the file - so it falls back using the standard filename based fallback to global_messages.properties.",[211,293,294],{},"Exactly the result we want - the ability to switch to norwegian or english with only one copy of each. A bit of a hack but it works.",[296,297,299],"h2",{"id":298},"note","Note",[211,301,302],{},"This is making it work by observation - my interpretation may be way off - however the result works for me.",[211,304,305],{},"If anyone knows a more correct solution (or description of the problem) feel free to add a comment - if there's a better way I want to be using it ;)",{"title":307,"searchDepth":308,"depth":308,"links":309},"",2,[310],{"id":298,"depth":308,"text":299},null,"2010-03-15 20:45:42 +0100","md",{},true,"\u002F2010\u002F03\u002F15\u002Fstruts2-i18n-where-application-default-locale-doesn-t-match-app-server-locale",{"title":206,"description":213},{"loc":316},"2010\u002F03\u002F15\u002Fstruts2-i18n-where-application-default-locale-doesn-t-match-app-server-locale",[321,322,323,324],"java","glassfish","struts2","struts 2.1.6","ji4QTL4QTNwFELWNtwfPf_UCQnjWXdA9prlJOWCg3z4",1775293014467]