Can someone tell me how to set language of a web page on the knowledge of IP address of visitor so that he automatically gets page in his country's language. Of course if that language is implemented by web developer. Even better I sow some examples of automatic Google translation of the text.
So how to achieve that visitor from USA gets text on my page in English and visitor from France in French. All that translated by Google from some third original language.
Thanks a lot.
When it come to automatic language selection I'd go the mod_rewrite route if you're using Apache. It's easier to change in a production environment that touching application code. mod_rewrite grabs the "Accept-Language" out of the header then applies the rewrite rule.
RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule ^$ /fr/ [L,R=301]
You can stack the rewrite conditions and rules to work as a catch all language variations (fr, fr-ca, fr-fr, fr-mo, fr-ch all go to fr)
Checkout the official mod-rewrite documentation
good language example:
http://tech-blog.borychowski.com/index.php/2009/03/htaccess/redirect-according-to-browser-language-mod-rewrite-and-http_accept_language/
Once you push the user to the right general language (when none is defined in the URL) the application can set a session language, write links with the set lang. It's also good to allow people to change language on the fly since most users in bilingual locals (i.e. Quebec) work in more than one language. I've worked with French speaking programmers who prefer reading technical documents in English.
When it comes to Google translating text I'd be careful. If you're doing any e-commerce transaction your international customers (or local customers with international browser settings) may get incorrect or inaccurate product information, descriptions and "terms and conditions". If you don't save the exact Google translation text to your DB for every on the fly translation there is no way to track what the user has committed to in their language. Some non-translated legal copy may be in order.
I hope this helps.
Either:
Guess language from location (which you can get from their IP).
Look at the request header's "accept-language" value.
To see what's in your request header, have a look here: http://www.ericgiguere.com/tools/http-header-viewer.html
This is a bad idea from the offset.
Geolocating on IP address doesn't always work (and doesn't work if you use TOR)
Even if you get this right, what would you do for countries like Canada or Switzerland?
Automatic translation is ok, but it would be better to tell someone that you don't have the site in their language - they may then prefer to read it in a different language.
Related
In my application I have localized urls that look something like this:
http://examle.com/en/animals/elephant
http://examle.com/nl/dieren/olifant
http://examle.com/de/tiere/elefant
This question is mainly for Facebook Likes, but I guess I will hit similar problems when I start thinking about search engine crawlers.
What kind of url would you expect as canonical url? I don't want to use the exact english url, because I want that people clicking the link will be forwarded to their own language (browser setting/dependent on IP).
The IP lookup is not something that I want to do on every page hit. Besides that I would need to incorporate more 'state' in my application, because I have to check wether a user has already been forwarded to his own locale, or is browsing the english version on purpose.
I guess it will going to be something like:
http://example.com/something/animals/elephant
or maybe without any language identifier at all:
http://example.com/animals/elephant
but that is a bit harder to implement, bigger chance on url clashes in the future (in the rare case I would get a category called en or de).
Summary
What kind of url would you expect as canonical url? Is there already a standard set for this?
I know this question is a bit old, but I was facing the same issue.
I found this:
Different language versions of a single page are considered duplicates only if the main content is in the same language (that is, if only the header, footer, and other non-critical text is translated, but the body remains the same, then the pages are considered to be duplicates).
That can be found here: https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls
From this I can conclude that we should add locales to canonicals.
I did find one resource that recommends not using the canonical tag with localized addresses. However, Google's documentation does not specify and only mentions subdomains in another context.
There is more that that language that you need to think of.
It's typical a tuple of 3 {region, language, property}
If you only have one website then you have {region, language} only.
Every piece of content can either be different in this 3 dimensional space, or at least presented differently. But this is the same piece of content so you'd like to centralize managing of editorial signals, promotions, tracking etc etc. Think about search systems - you'd like page rank to be merged across all instances of the article, not spread thinly out.
I think there is a standard solution: Canonical URL
Put language/region into the domain name
example.com
uk.example.com
fr.example.com
Now you have a choice how you attach a cookie for subdomain (for language/region) or for domain (for user tracking)!
On every html page add a link to canonical URL
<link rel="canonical" href="http://example.com/awesome-article.html" />
Now you are done.
There certainly is no "Standard" beyond it has to be an URL. What you certainly do see on many comercial websites is exactly what you describe:
<protocol>://<server>/<language>/<more-path>
For the "language-tag" you may follow RFCs as well. I guess your 2-letter-abbrev is quite fine.
I only disagree on the <more-path> of the URL. If I understand you right you are thinking about transforming each page into a local-language URL? I would not do that. Maybe I am not the standard user, but I personally like to manually monkey around in URLs, i.e. if the URL shown is http://examle.com/de/tiere/elefant, but I don't trust the content to be translated well I would manually try http://examle.com/en/tiere/elefant -- and that would not bring me to the expected page. And since I also dislike those URLs http://ex.com/with-the-whole-title-in-the-url-so-the-page-will-be-keyworded-by-search-engines my favorite would be to just exchange the <language> part and use generic english (or any other language) for <more-path>. Eg:
http://examle.com/en/animals/elephant
http://examle.com/nl/animals/elephant
http://examle.com/de/animals/elephant
If your site is something like Wikipedia, then I would agree to your scheme of translating the <more-part> as well.
Maybe this Google's guidelines can help with your issue: https://support.google.com/webmasters/answer/189077?hl=en
It says that many websites serve users (across the world) with content targeted to users in a certain region. It is advised to use the rel="alternate" hreflang="x" attributes to serve the correct language or regional URL in Search results.
This question may be impractical and may be stupid, so please pardon me.
I want to change the LANGUAGE OF URL.
For example,
If the URL is
www.google.com
I just want to translate it to another Language(HERE 'MALAYALAM- An Southern Indian Language'). In Malayalam "Google" looks like "ഗൂഗിള്" . Means I just want to display in my address bar as www.ഗൂഗിള്.com instead of www.google.com.
Simply, how can I create default english URL to alternate language URL. PHP, Javascript, Jquery are preferred.
There is no technical solution to this. The only way to do it is to purchase the actual domain ഗൂഗിള്.com and to host a web site under it.
That domain name, however, is already taken and points to a Google search form.
See Wikipedia on Internationalized Domain Names
I have my personal website made with Sphinx. It generates static HTML pages. Currenty, the content is just in English or German only. I would like to expand this to multiple languages. I do not know how to structure my URLs, yet.
The following should be done:
Static folders like /_download, /_download and /_images must still be on the server only once, I do not have that much space.
The languages might be on equal footing, but that is not that important.
Old URLs still work without a problem and default to English. I do not want to cause a single 404 error.
I currently have the following ideas:
Put the English site on `example.de/, put the German site on de.example.de/ and redirect de.example.de/_download to example.de/_download with a .htaccess file.
Put the English site on example.de/ and put the German site on example.de/de/. Redirects as above.
English site on en.example.de/ and German on de.example.de/. And redirect for all languages.
English site on example.de/en/ and German on example.de/de/. Redirects as above.
What would make the most sense?
While the .de domain suffix indicates Germany, many folks associate .de with German. Displaying English by default adds confusion, which acts as a roadblock to those seeking other languages.
Setting the English site on en.example.de and German on de.example.de is most consistent, and will be most easily intuited by your multi-lingual audience.
Another option, which was not listed by the OP, would be to set the English site on example.de/en, and German on example.de/de.
In preparation to internationalize our Rails app, I'm finding we need to create a countries table and model that would contain (among other things) the default locale for each country. I found a 4 year old resource http://snippets.dzone.com/posts/show/1727 that has most of what I want, but not locale. Does everybody have to piece this part together by hand or am I overlooking some easier way to map country to a default locale.
P.S. We already look up a users country using GeoIpCountry which works nicely, but that table only provides country name and 2-letter abbreviation. I also want to use country to assign the users default locale, currency, and 3-letter abbreviation (needed by a third party integration)
The best way to identify user's locale is to look up the HTTP request's Accept-Language setting.
e.g., mine says: Accept-Language: fr-BE
Which gives you my locale, my language (fr: french) and my country (BE: Belgium).
Also, remember that locale identification based on country is wrong in many countries, such as mine: Many websites identify my country (Belgium) correctly and assume a default locale: nl-BE because 60% of belgian people speak Dutch (nl). Hence these sites have it wrong for 40% of belgian visitors (including me).
Their site is a bad experience for me because it displays in a language which is not mine and the first thing I must do is look for their tiny language popup menu.
Had they simply looked up my Accept-Language, they would have shown me their site in my language right away.
have a look at: https://github.com/mm1/country-list
I have a multilingual site with the same content in different languages with descriptive seo urls incorporating the title of each pages article. To switch between said languages of translated articles I have an action which looks up the translated title using the previous language and redirects to it. This all works fine except I noticed, despite there being no view, google has indexed said redirect urls.
Is this bad practice? I don't want to 301 redirect as it seems having links on every page to 301 redirects is a really bad idea. Do I somehow include a meta tag or is there some other approach?
The reason I currently have this is I want each article page to link to all of its translations using flags at the top of each page. The more I think about it I should just generate the direct url as this itself may have seo benefits. The reason I didn't go down this path originally was page rendering speed. I'd have to look up multiple articles solely for their url slug and expire caches of all languages upon any title change (it's a wiki style user generated content). Also, in some cases a translation wouldn't exist in which case I would need to link instead, say, to the category of article with a flash message.
So thinking through this while writing maybe this seems the preferable if more difficult to implement solution?
Hey Mark, from a search engine perspective you definitely don't want to rely on redirects everywhere, if for nothing other than performance. Search engines allocate a certain amount of bandwidth to each site based on ranking, if you're redirecting every page, you're eating up more of that bandwidth than you need to, and potentially not getting as much content crawled as you could otherwise.
Your second solution of generating the localized URLs and sticking them at the top of the page is the best option for search engines. That will give a unique URL for each page, and will provide a direct link to each page that Google and Bing (e.g. Yahoo) can follow and index.
I provided a set of best practices for SEO & Localized sites on another stackoverflow Q&A, here's a link, I think you'll find it valuable too: Internationalization and Search Engine Optimization
Good luck!
I have an app that I'm building that supports ten languages: English, simplified and traditional Chinese, French, Spanish, Russian, Japanese, German, and Hindi.
I tried a number of things but what I ended up doing was making :en default and then switching by where the request was coming from and then when uses signup they can set a default language. So if it was coming from mainland China I use :scn, and if it comes from Hong Kong I use :tcn traditional Chinese/simplified Chinese.
This way the application maintains a state of a language and there is no redirection.
I think any redirection is going to be troublesome so I wouldn't do that. Also, I am working on a dynamic site map that will list all of the links to google, which will have 10 different translations per 'page'.
I haven't deployed my application yet so I cannot check the Chinese search engines etc... to see if they are indexing my content.