It depends.
You can use a third party service to map a user's IP-address to a country, and even cities.
MaxMind has great such service.
You could also use the browser's settings to detect what language the browser is using. This will be possible with .htaccess