View Javadoc
1 package org.neuclear.commons.servlets; 2 3 import javax.servlet.http.HttpServletRequest; 4 import java.util.*; 5 6 /* 7 * The NeuClear Project and it's libraries are 8 * (c) 2002-2004 Antilles Software Ventures SA 9 * For more information see: http://neuclear.org 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 */ 25 26 /*** 27 * User: pelleb 28 * Date: Jun 6, 2004 29 * Time: 3:01:56 PM 30 */ 31 public class ServletMessages { 32 private ServletMessages() { 33 }; 34 35 public static ResourceBundle getMessages(String name, HttpServletRequest request) { 36 final Locale locale = request.getLocale(); 37 System.out.println("locale " + locale.getLanguage()); 38 System.out.println("encoding " + System.getProperty("file.encoding")); 39 final String key = name + "_" + locale.getLanguage(); 40 if (!bundles.containsKey(key)) { 41 System.setProperty("file.encoding", "UTF-8"); 42 ResourceBundle messages = ResourceBundle.getBundle(name, locale); 43 bundles.put(key, messages); 44 } 45 return (ResourceBundle) bundles.get(key); 46 } 47 48 private static final Map bundles = Collections.synchronizedMap(new HashMap()); 49 }

This page was automatically generated by Maven