- From: Denis Tea via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 11 Feb 2008 14:17:58 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn/tests In directory hutz:/tmp/cvs-serv20681/org/w3c/unicorn/tests Modified Files: FirstServlet.java Log Message: DoPost OK for internalization Index: FirstServlet.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tests/FirstServlet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FirstServlet.java 22 Jan 2008 13:55:09 -0000 1.4 +++ FirstServlet.java 11 Feb 2008 14:17:56 -0000 1.5 @@ -139,7 +139,7 @@ templateLang = aHttpServletRequest.getParameterValues("ucn_lang")[0]; } else - templateLang = aLocale.toString(); + templateLang = LocalizedString.DEFAULT_LANGUAGE; mapOfOutputParameter.put("lang", templateLang); @@ -224,32 +224,44 @@ mapOfOutputParameter.put("format", "xhtml10"); mapOfOutputParameter.put("charset", "UTF-8"); mapOfOutputParameter.put("mimetype", "text/html"); - final Locale aLocale = aHttpServletRequest.getLocale(); - if (null == aLocale) { - mapOfOutputParameter.put("lang", LocalizedString.DEFAULT_LANGUAGE); - aUnicornCall.setLang(LocalizedString.DEFAULT_LANGUAGE); - - } else { - mapOfOutputParameter.put("lang", aLocale.toString()); - - //aUnicornCall.setLang(aLocale.toString()); - aUnicornCall.setLang("fr"); - } + // Returns the preferred Locale that the client will accept content in, + // based on the Accept-Language header + final String aLocale = aHttpServletRequest.getHeader("Accept-Language"); + + + // Language of the template + // ucn_lang is a parameter which is define in xx_index.html.vm. + // It is an hidden parameter of a form. + String templateLang = LocalizedString.DEFAULT_LANGUAGE; + + FirstServlet.logger.trace("doPost"); + + + final Map<String, String[]> mapOfSpecificParameter = new Hashtable<String, String[]>(); FileItem aFileItemUploaded = null; + try { listOfItem = FirstServlet.upload.parseRequest(aHttpServletRequest); + // Process the uploaded items for (final Iterator aIterator = listOfItem.iterator(); aIterator.hasNext();) { final FileItem aFileItem = (FileItem) aIterator.next(); if (aFileItem.isFormField()) { + + if(aFileItem.getFieldName().equals("ucn_lang")) { + templateLang = aFileItem.getString(); + } + + addParameter(aFileItem.getFieldName(), aFileItem.getString(), - aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter); + aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter); + } else if(aFileItem.getFieldName().equals("ucn_file")) { aFileItemUploaded = aFileItem; aUnicornCall.setDocumentName(aFileItemUploaded.getName()); @@ -257,7 +269,16 @@ aUnicornCall.setEnumInputMethod(EnumInputMethod.UPLOAD); } } + + if (null == aLocale) { + aUnicornCall.setLang(LocalizedString.DEFAULT_LANGUAGE); + } else { + aUnicornCall.setLang(templateLang + "," + aLocale); + } + mapOfOutputParameter.put("lang", templateLang); + } + catch (final FileUploadException aFileUploadException) { FirstServlet.logger.error( "FileUploadException : "+aFileUploadException.getMessage(), @@ -271,7 +292,8 @@ try { aUnicornCall.doTask(); - + + this.createOutput( aHttpServletResponse, aUnicornCall,
Received on Monday, 11 February 2008 14:18:09 UTC