java - Maven default locale not same with OS locale -


when type

mvn --version 

in command prompt see:

default locale : en_us

however system locale tr_tr

when start java se project without maven , run locale.getdefault() tr_tr returns fine. when run maven project , locale.getdefault() returns en_us not like.

how can tell maven default locale tr ?

you can use command

set maven_opts= -duser.language=tr 

anyway best solution put these informations in pom file , never command line. in particular have deal configuration of maven-surefire-plugin

    <plugin>         <groupid>org.apache.maven.plugins</groupid>         <artifactid>maven-surefire-plugin</artifactid>         <version>2.9</version>         <configuration>             <systempropertyvariables>                 <user.language>tr</user.language>                 <user.region>tr</user.region>             </systempropertyvariables>         </configuration>      </plugin> 

second question: another question if may, running web app in locale supports lets german, english.. , system locale de. can system locale request? or maybe language prefer browser?

you can take these informations request. here example in servlet.

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.locale;  public class getlocale extends httpservlet{    public void doget(httpservletrequest request,httpservletresponse response)throws servletexception, ioexception   {       locale locale = request.getlocale();       string language = locale.getlanguage();       string country = locale.getcountry();        response.setcontenttype("text/html");       printwriter out = response.getwriter();        out.println(language + ":" + country);   } } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -