Reputation: 539
I have to show a html page in french. the page .
I have use the HTML tag like below
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
I have used the google translater in my page.First time When I place this It was automatically changed whole page into French. Now not working please help.
Upvotes: 0
Views: 2396
Reputation: 201846
The problem is in the way you call the Google translator. The pageLanguage
property specifies the source language, so it must be en
. (It could also be omitted, but then the translator would start making its guesses.) The destination languags(s) are to be specified in the includedLanguages
property. To fix French as the destination language, you would use fr
there. If the code
function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: 'fr', layout: google.translate.TranslateElement.InlineLayout.SIMPLE,autoDisplay: false, includedLanguages: ''}, 'google_translate_element');}
is thus replaced by
function googleTranslateElementInit() {
new google.translate.TranslateElement(
{pageLanguage: 'en',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
autoDisplay: false, includedLanguages: 'fr'},
'google_translate_element');}
then the page appears with a widget for translation from English to (broken) French. If you leave includedLanguages
to the empty value ''
, there will be a menu of destination languages in the widget. That’s the closest you can get I suppose; it seems to be Google’s intention that the translation works via user actions.
(Original text, mistaken:
then the page is automatically translated from English to (broken) French. You may wish to set #google_translate_element { display: none }
in CSS then, since the translate widget is of no use and just confuses people. Alternatively, if you leave includedLanguages
to the empty value ''
, Google translate will generate a language menu for the user.)
I strongly support Quentin’s advice on avoiding automatic translation of web pages, at least when used this way. Google translate produces translations that may look OK on the surface, and some sentences may look rather good, but it also produces incomprehensible mixes of words and, worse still, translations that look fairly good but have the content all wrong (though this worst case is not as common as it used to be, as they have presumable tuned their technologies).
Upvotes: 1
Reputation: 972
Sir you enter DOCTYPE for HTML4...
html lang attribute will work normally with html doctype.
Try it :
<!DOCTYPE html>
Upvotes: -1
Reputation: 944320
HTML has no facilities to automatically translate content. The lang
attribute means "The content of this element is written in this language". (This is used as a pronunciation guide for text to speech software, and as a hint to automated translation software that takes HTML as input).
The only sensible approaches to translating content for the WWW are:
Automated translation is not very good, so you should not present it to end users yourself. It implies that the poor translation is something that you think is good enough to publish (it won't be).
Upvotes: 3