Categories
discuss

Website that recognizes user’s location/IP & changes lang. based on that

title is pretty clear.

My websites consists of both English-written and Spanish-written versions. You can go to the main site, which is in Spanish, by clicking http://www.chrishonn.com and to the translated version, which is in English, at http://en.chrishonn.com. At the index of each page there is a link (at the bottom) which allow the user to pass from one site to the other.

However, I was wondering, how do big sites like Google, Yahoo!, and other brands’ websites to recognize the user’s geographical location/IP so that – depending on that – the site’s language is adapted (i.e. you are from China and you visit www.google.com, you’ll be redirected to www.google.cn).


I have stated on every single page of my website the language:

<meta http-equiv="content-language" content="en">

That example is of course from one of the http://en.chrishonn.com sites, which are in English.

I hope someone can give me a hand. Thank you (if I missed something, please let me know).

Answer

As for Google, your location is determined from your IP address. A request to google.com from outside the US returns an HTTP/1.1 302 Found which redirects you to your country specific domain.

As also discussed on another post, doing these kinds of redirects can make SEO tricky and complicated. I suggest reading Matt Cutt‘s article (a Google software engineer) on how Google handles the 302 Redirect: SEO advice: discussing 302 redirects.

Different search engines handle the 302 redirect in a different way. With 302 redirects, you may risk having your original domain ignored by search engines.


If you want to determine your users’ location from their IP address, there are many off-the-shelf services which basically map most of the IP ranges to countries. You may want to check:


Another popular technique is to parse the Accept-Language HTTP header, which contains information about the user’s language preferences. Mainstream browsers allow these language preferences to be modified by the user. You may read more about this technique from:


Categories
discuss

Java JRE 64-bit download for Windows?

I’m working on a web site project with a Java component and am currently testing for cross-browser compatibility. Most is fine but the Java part won’t load on 64-bit browsers. Looks like I need a 64-bit JRE to test. Where does one download the (off-line) 64-bit Java runtime installer for Windows?

The official download page is here: http://www.java.com/en/download/manual.jsp

Unless I’m blind, nothing 64-bit there for Windows except a link to notes. Said notes are here: http://www.java.com/en/download/faq/java_win64bit.xml#Java%20for%2064-bit

Particularly relevant excerpt:

“Users should download 64-bit Java software, if they are running 64-bit
IE. For downloading 64-bit Java click 64-bit manual download

The only off-line installer, as far as I can tell, has only installed the 32-bit runtime. Then we’re back at square one! Am I missing something or going nuts?

Answer

Might this be the download you are looking for?

  1. Go to the Java SE Downloads Page.
  2. Scroll down a tad look for the main table with the header of “Java Platform, Standard Edition”
  3. Click the JRE Download Button (JRE is the runtime component. JDK is the developer’s kit).
  4. Select the appropriate download (all platforms and 32/64 bit downloads are listed)
Categories
discuss

Java-Mac OS X integration without breaking platform independence

I want my application to integrate Mac OS X better. I’ve read Mac OS X Integration for Java and I’ve learned I have to import com.apple.eawt.* and write some extra code. But, if I do this, my application is not going to work on Windows because of missing reference. I could do this with preprocessor command if I write in C but this is Java. How can I do this without separating the code file into 2 branches?

Answer

Macify it.

Categories
discuss

Java OpenCV Bindings

I am looking for OpenCV java bindings, all the references point to the processing library. I know processing is java but isn’t there a standalone java lib? or should just use processing libs?

Answer

I have just found this, a java wrapper of OpenCV :
https://github.com/bytedeco/javacv

Not tested, but I would love to have your point of view about this.

Categories
discuss

Sorrounding Logger with an If clause to avoid redundant String construction

I got a recommendation to use this syntax when logging in java:

if (logger.isLoggable(Log.FINE))
{
    logger.fine("bla"+" bla"+" bla");
}

The reason for this is to avoid the redundant construction of the parameter string incase the logging level is lower than “FINE”. (in the example above – 5 redundant string object. (” bla”X3, ” bla bla” and “bla bla bla”).

I’d like to hear what others are doing about this or if you think that this is necessary at all.

Thanks!!

Answer

Some newer logging frameworks allow you to specify arguments as parameters, and won’t evaluate them if there’s no logging.

The example I found is LogBack, the successor to Log4j. Here’s the info: http://www.infoq.com/news/2007/08/logback

This gives you the best of both worlds, so to speak. Elegant syntax yet good performance.


Log4j code example:

if( logger.isDebugEnabled() ) {
  logger.debug( "User with account " + 
    user.getAccount() + " failed authentication; " +
    "supplied crypted password " + user.crypt(password) +
    " does not match." );
}

Equivalent LogBack code:

logger.debug( "User with account {} failed authentication; " +
    "supplied crypted password {} does not match.",
    user.getAccount(), user.crypt(password) );

This defers the cost of message assembly until LOGBack has ascertained whether or not this message will be viewed. It doesn’t defer the cost of retrieving expensive parameters, such as the password crypting in the above example.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..