Re: How to know the country of the user

2012-10-28 Thread Wujek Srujek
Glad I could help. Please note, though, that Locale.getCountry() might be
null, or Locale.getLanguage() might be null, but both being null result in
an 'undefined' locale. You might want to take this into account.

wujek

On Sun, Oct 28, 2012 at 6:45 PM, Paolo  wrote:

> Alle domenica 28 ottobre 2012, Wujek Srujek ha scritto:
> > Locale has more information than just the language. For example: en_US
> > is English in USA; en_UK is English in the UK, it_IT is Italian in Italy,
> > but it_CH is Italian in Switzerland. Your example would differentiate
> > between pt_PT (Portuguese in Portugal) and pt_BR (Portuguese in Brazil).
> > Check out Locale.getCountry().
> > This being said, it is still not the same as the physical location. Do
> you
> > really need the country of residence for some statistics / whatever, or
> the
> > language / regional settings for localization? In the former case, Locale
> > won't help; in the latter, the physical location is probably not the
> right
> > way to go, Locale is.
> > For example, I'm Polish but live in Germany, and I would like your
> > application display Polish strings (or English).
>
> Thank you so much, for your reply.
> I don't need the physical location, so  Locale.getCountry() is enought for
> me,
> and so faster and easy than my idea.
>
> Thank you so much!
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: How to know the country of the user

2012-10-28 Thread Paolo
Alle domenica 28 ottobre 2012, Wujek Srujek ha scritto:
> Locale has more information than just the language. For example: en_US
> is English in USA; en_UK is English in the UK, it_IT is Italian in Italy,
> but it_CH is Italian in Switzerland. Your example would differentiate
> between pt_PT (Portuguese in Portugal) and pt_BR (Portuguese in Brazil).
> Check out Locale.getCountry().
> This being said, it is still not the same as the physical location. Do you
> really need the country of residence for some statistics / whatever, or the
> language / regional settings for localization? In the former case, Locale
> won't help; in the latter, the physical location is probably not the right
> way to go, Locale is.
> For example, I'm Polish but live in Germany, and I would like your
> application display Polish strings (or English).

Thank you so much, for your reply.
I don't need the physical location, so  Locale.getCountry() is enought for me,
and so faster and easy than my idea.

Thank you so much!

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to know the country of the user

2012-10-28 Thread Wujek Srujek
Locale has more information than just the language. For example: en_US
is English in USA; en_UK is English in the UK, it_IT is Italian in Italy,
but it_CH is Italian in Switzerland. Your example would differentiate
between pt_PT (Portuguese in Portugal) and pt_BR (Portuguese in Brazil).
Check out Locale.getCountry().
This being said, it is still not the same as the physical location. Do you
really need the country of residence for some statistics / whatever, or the
language / regional settings for localization? In the former case, Locale
won't help; in the latter, the physical location is probably not the right
way to go, Locale is.
For example, I'm Polish but live in Germany, and I would like your
application display Polish strings (or English).

wujek

On Sun, Oct 28, 2012 at 5:52 PM, Paolo  wrote:

> Alle domenica 28 ottobre 2012, Andrea Del Bene ha scritto:
> > You should try Session.get().getLocale(). By default Session returns the
> > locale of the underlying HttpServletRequest.
>
> getLocale return the languange set in the browser, and it is not the same
> thing of country.
>
> You are right for example for me that I am italian, so my language (it) is
> the same of the country (it)
>
> But for example if your country may be Brazil (br), but language is
> portuguese.
>
> The same is for language espanol (es), that is speaking in many countries.
>
>
>
>
> > > How can I know the country of the user that is connected to my wicket
> page?
> > >
> > > I only suppose to check the IP address with:
> > >
> > > String ipAddress = ((ServletWebRequest)
> RequestCycle.get().getRequest()).getContainerRequest().getRemoteHost();
> > >
> > > And than with command line whois check the country
> > >
> > > whois 109.113.243.xx |grep -E 'country|Country'
> > >
> > > or use a free database:
> > >
> > > http://dev.maxmind.com/geoip/geolite.
> > >
> > > If you know some wicket library, or better way, please tell me.
> > >
> > > -
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: How to know the country of the user

2012-10-28 Thread Paolo
Alle domenica 28 ottobre 2012, Andrea Del Bene ha scritto:
> You should try Session.get().getLocale(). By default Session returns the 
> locale of the underlying HttpServletRequest.

getLocale return the languange set in the browser, and it is not the same thing 
of country.

You are right for example for me that I am italian, so my language (it) is the 
same of the country (it)

But for example if your country may be Brazil (br), but language is portuguese.

The same is for language espanol (es), that is speaking in many countries.




> > How can I know the country of the user that is connected to my wicket page?
> >
> > I only suppose to check the IP address with:
> >
> > String ipAddress = ((ServletWebRequest) 
> > RequestCycle.get().getRequest()).getContainerRequest().getRemoteHost();
> >
> > And than with command line whois check the country
> >
> > whois 109.113.243.xx |grep -E 'country|Country'
> >
> > or use a free database:
> >
> > http://dev.maxmind.com/geoip/geolite.
> >
> > If you know some wicket library, or better way, please tell me.
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to know the country of the user

2012-10-28 Thread Andrea Del Bene
You should try Session.get().getLocale(). By default Session returns the 
locale of the underlying HttpServletRequest.

How can I know the country of the user that is connected to my wicket page?

I only suppose to check the IP address with:

String ipAddress = ((ServletWebRequest) 
RequestCycle.get().getRequest()).getContainerRequest().getRemoteHost();

And than with command line whois check the country

whois 109.113.243.xx |grep -E 'country|Country'

or use a free database:

http://dev.maxmind.com/geoip/geolite.

If you know some wicket library, or better way, please tell me.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



How to know the country of the user

2012-10-27 Thread Paolo
How can I know the country of the user that is connected to my wicket page?

I only suppose to check the IP address with:

String ipAddress = ((ServletWebRequest) 
RequestCycle.get().getRequest()).getContainerRequest().getRemoteHost();

And than with command line whois check the country

whois 109.113.243.xx |grep -E 'country|Country'

or use a free database:

http://dev.maxmind.com/geoip/geolite.

If you know some wicket library, or better way, please tell me.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org