Conditional translation header for translation of web documents

Methods, systems, and apparatus, including computer program products, for translation of web documents. The original language of document text in the web document is identified. A translation header is displayed with the web document text only if the original language is different from a user's preferred language. The translation header provides the user with an option of translating the document text or portions of the document text to the user's preferred language.

BACKGROUND

This specification relates to translation of text in web documents.

The proliferation of the Internet has made web documents in many different languages readily accessible to users. Various web document translation mechanisms are available to assist a user in reading web document text displayed in a language unfamiliar to the user. Typically such translation mechanisms are integrated into and accessible through a toolbar of a web browser program or are provided by the web page itself (e.g., a script embedded within the web page). However, the translation cues provided by these translation mechanisms are static, i.e., shown to users regardless of the language in which the text of a web document is displayed.

Another translation mechanism is integrated into a search results page that displays search results. A search result includes a web page title, a snippet of text extracted from the web page, and the URL of the web page. The URL can be provided in the form of a resource link to the web page referenced by the search result. If the text of the web page referenced by a search result is in a language that is different from a preferred language specified for a browser on which the search results are displayed, the search results page can include a selectable option to translate the web page referenced by the search result. However, the user must select the option to translate the web page from within the search results page, and cannot select the option to translate the page from the actual web page itself.

SUMMARY

In general, the subject matter of this specification describes technologies relating to conditional translation headers for translating web document text.

In general, one aspect of the subject matter described in this specification can be implemented in methods that include receiving, at a client device, a document comprising document text in a first language to be displayed on the client device; displaying, at the client device, the document text of the document; identifying, at the client device, a second language to which the document text may be translated; determining that the second language is different from the first language and displaying, only in response to the determination, a translation header with the document text, the translation header including text in the second language describing a selectable option in the translation header to translate document text from the first language to the second language; and in response to a selection of the selectable option: identifying, at the client device, a portion of the document text to be translated; sending a request from the client device to a translation server to translate the portion of the document text from the first language to the second language; in response to the request, receiving at the client device translation data including a corresponding translated portion of the document text in the second language; and displaying, at the client device, the translated portion of the document text of the document.

Particular embodiments of the subject matter described in this specification can be implemented so as to realize one or more of the following advantages. The translation header is shown on a rendered web document (e.g., a web page) only when appropriate, such as when the web document text is in a language other than a user preferred language.

Selectively displaying the translation header eliminates the display footprint of the translation header when translation is not needed, thus maximizing the display area for the web document content.

When translation of web document text is determined to be needed, the translation header is prominently displayed with the web document text. Such a configuration permits a user to quickly identify that translation is available and request translation of the web document text without navigating through a menu or searching for a translation mechanism on the web document or in a toolbar of the operative web browser program.

Additionally, when a document is provided in response to selecting a search result, the user need not navigate back to the search result page to request a translation of text within the web document if a translation of web document text is determined to be needed. Instead, the translation header is prominently displayed with the web document text and the user may request a translation from within the web document.

DETAILED DESCRIPTION

This specification relates to displaying a conditional translation header in a rendered web document only if the web document includes text in a language other than one or more specified languages, such as a user's preferred language. A web document is a document annotated with a markup language that is provided to or accessible by a client device over a network, such as the Internet. An exemplary web document is an HTML document, which can be rendered on the client device by use of a web browser program.

The translation header is an interactive object that provides a selectable option allowing a user to request translation of the web document text to a specified language different from the language in which the web document text is originally displayed to the user. In some implementations, a script (i.e., executable or interpreted program instructions) is included in the web document and executed by the web browser program. The script causes the web browser program to display the translation header only if the client device (e.g., by execution of the script) determines the language of the web document text to be different from a specified language associated with the client device.

A client device is an electronic device that is under control of a user and is capable of requesting and receiving web documents and other content over a network, such as the Internet or an intranet. Example client devices include personal computers, mobile communication devices, and other devices that can send and receive data over the network.

Display format110includes web document text140in an original language and does not include a conditional translation header. The web document105is displayed in display format110if the original language of the web document text is the same as a specified language of a client device. For example, the web document105will be displayed in the display format110if the original language is English and specified language of a client device is also English.

Display format120includes web document text140in an original language and a conditional translation header142with translation header text in a specified language, such as a preferred user language that is different from the original language. The web document105is displayed in display format120if the original language of the web document text140is different from the specified language of a client device, and if the translation process for the web document text has not been initiated and/or completed. For example, the web document105will be displayed in the display format120if the original language is English and the specified language is German, and the translation process for the web document text140has not been initiated.

Display format130includes web document text140′ in the specified language and the translation header text in the specified language. The web document105is displayed in display format130if the original language of the web document text is different from the specified language and the translation process for the web document text has been completed. For example, the web document105will be displayed in the display format130if the original language is English and the specified language is German, and the translation process for the web document text140has been completed.

For each of the display formats110,120and130, the same web document is used, e.g., the same HTML document. The translation header142, however, is only shown if the original language of the web document text140is different from the specified language of a client device

FIG. 2illustrates an example display202of a web document205and an example display204of a translated version of the web document205. The example displays202and204are generated by a web browser program on a client device for which the English language is specified.

In example display202the web browser displays the web document205with web document text240in the original language and a conditional translation header246with translation header text in the specified language (e.g., display format120of FIG. I B). For example, in the display202the original language of the web document text240is Spanish and the specified language of the client device is English. The translation header246includes translation header text prompting an input for translation of the web document text240, e.g., “Translate this page?” and, optionally, translation header text identifying the original language of the web document text240, e.g., “This page is in Spanish.”

The input prompted by the translation header text can be, for example, user selection of a selectable option such as a “Translate” button206. In some implementations the translation header text also identifies the specified language (e.g., the preferred language). For example, the translation header246may include the text “Translate this page from Spanish to English?” The translation header246illustrated in and described with reference to display202is a first display configuration of the translation header246. For example, the translation header246is displayed in the first display configuration prior to a selection of the selectable translate option, e.g., Translate button206.

In some implementations, a selectable option in the translation header can allow a user to identify the original language of the web document text240, as opposed to relying on, for example, an automated language identification process. Optionally, or alternatively, the translation header selectable option can allow a user to identify the language to which the web document text240is to be translated. These options permit a user to explicitly define the language of the web document text240and/or the language to which the web document text240will be translated.

In some implementations, the translation header246also includes a language selection option208to allow a user to select another language to which the web document text240is to be translated. For example, the language selection option208can be a drop down menu listing available languages. Selection of a language from the language selection option208causes the web document text to be translated and displayed in the selected language.

In some implementations, the translation header246also includes another selectable option210to return the display of the web document as shown in display204to display202. Thus selecting the selectable option210causes the browser to display the web document text240in the original language, i.e., Spanish. The translation header246illustrated in and described with reference to display204is displayed in a second display configuration. For example, the translation header246is displayed in the second display configuration subsequent to a selection of the selectable translate option, e.g., Translate button206.

FIG. 3illustrates an example architecture of a system300that provides a conditional translation header for translation of web document text312in a web document306. A client device302runs a web document display program, e.g., a web browser304, to render the web document306.

The web document306includes web document text312and a translation header element310. The web document text312is textual content displayed when the web browser304renders the web document306. The translation header element310is program code (e.g., JavaScript) executable by the web browser304. The translation header element310provides for the display of the translation header246and the functionality of the translation header246.

For convenience, when the translation header element310is described as performing actions, it is meant that the web browser304is executing the program code defined by the translation header element310to cause the actions to be performed.

In some scenarios, the original language of the web document text312is specified in the web document306or specified in metadata retrieved with the web document306. For example, the publisher of the web document306may embed data identifying the original language, such as a language tag.

In other examples, the web document306may be handled by an agent before reaching the web browser304, such as an email message being handled by an email server. The agent or a system responsive to the agent may process the web document306to identify the original language or language(s) of the text of the web document and then send data identifying the original language(s) to web browser304along with the web document306.

In such scenarios described above, the translation header element310identifies the original language from the provided information. However, if the original language is not specified in the web document306or associated metadata, then in some implementations the translation header element110can query, for example, a translation server308for identification of the original language. In other implementations the translation header element310can receive input (e.g., from a selectable option displayed in the translation header) from a user identifying the original language, for example, from a drop down menu or a text box rendered by the web browser304. In still other implementations, the translation header element310can access a language identification program resident on the client device302. The language identification program can process the text of the web document306to identify the language(s) of the web document text312. Any number of known language identification or detection techniques can be used by the client device or translation service.

The translation header element310identifies one or more specified languages (“second languages”) in which web document text312is to be displayed on the client device302. The specified languages are typically languages that the user of the client device302prefers. These preferences can be either explicit or implicit, and thus the specified languages can be identified in numerous ways. For example, from a network server side, the specified languages can be identified from various source indicators such as an (A) HTTP request header (Accept-Language), (B) a last-changed target language (e.g., second language) used by, for example, the translation header element310and saved in a cookie on the client device and reported by the translation header element310, (C) a last-used target language with a translation server/service, or (D) a last-used user interface language with a translation server/service. From a client device side, the specified languages can be identified from, for example, (E) web browser settings or (F) URL parameters (e.g., a query parameter).

If more than one specified language is identified (e.g., from one or both of the server side or client device side) then the specified languages can be ordered or prioritized according to their source and/or how recently a corresponding translation occurred. In some implementations, the translation header element310can prioritize (e.g., order) the specified languages, for example, according to a source ranking/ordering hierarchy. For example, the hierarchy may dictate that the second language is determined by the following scheme with reference to the itemization above: (F)>(B)>(C)>(D)>(E)>(A). Thus in this example the specified language identified from the URL parameter (F), if present, is the second language to which the text is translated (i.e., a highest ordered second language). In some implementations, the specified language identified from the URL parameter (F) may be the most reliable source for identifying the specified language. However, other schemes and hierarchies can be used.

The translation header element310determines whether the original language is different from the specified language (e.g., the selected, specified language if more than one). If the languages are different, then the translation header element310causes the web browser304to concurrently display the translation header246, with translation header text in the specified language, with the web document text312in the original language, and any other display content included in the web document306, such as images (e.g., display format120ofFIG. 1B). If the languages are not different, then the web document text312and any other display content included in the web document306are displayed without the translation header246(e.g., display format110ofFIG. 1A).

The translation header element310can detect selections of selectable options in the translation header, such as a user click on the Translate button206. In response to the selection of the selectable option206, translation header element310identifies the web document text312to be translated or a portion of the web document text to be translated (i.e., if less than all of the web document text is eligible for being translated by the translation server308). In some implementations, from the displayed web document text, a user can select the portion of web document text312to be translated by, for example, selecting certain web document text312with a mouse or other user input device.

In some implementations, the translation header element310, or more generally the web browser304, can identify the web document text312to be translated or the portion of the web document text312to be translated by use of a document object model (DOM) representation of the web document306. For example, the web browser304can include a layout engine314to parse the web document306to generate a DOM representation or, equivalently, a data structure representation of the document306. In some implementations, the layout engine314is distinct to the web browser304, but is in data communication with the web browser304and works in concert with the web browser304to render web documents. The DOM representation provides a conduit through which scripts executed by the web browser304can inspect and modify the web document306. For example, the DOM representation permits the translation header element310to identify and access web document text312in the web document for translation.

FIG. 4illustrates an example DOM representation of a web document400having web document text and a translation header element. The DOM representation represents a web document as a hierarchical arrangement of nodes with each node corresponding to a portion of the web document. There are various types of nodes, for example, root nodes (e.g., the root node404), element nodes (e.g., the title element node406), text nodes (e.g., text nodes408,410,412) and script nodes (e.g., script node414). A text node is a node corresponding to web document text (e.g.,312) in the web document (e.g.,306), and includes text stored in the node. An element node is a node corresponding to an annotation in the web document such as a markup language annotation. A script node includes an executable script in the web document such as the translation header element. The arrangement of the nodes is determined by the hierarchical relationships between the nodes. The hierarchical relationships of the nodes are attributable to nested annotations in a web document.

Once the translation header element310has identified the web document text312to be translated (e.g., by use of the DOM representation), the translation header element310sends a request to the translation server308to translate the relevant web document text312to the specified language. In response to the request, the translation server308provides translation data to the client device302. The translation data include the translated web document text in the specified language. The web browser304can render the web document306with translated web document text (e.g., display format130ofFIG. 1C).

FIGS. 5A and 5Drespectively are flow diagrams for an example method of translating text in email web pages, and an alternate example method of translating text in email web pages.FIGS. 5B and 5Crespectively illustrate an example display560of an HTML email page, and an example display540of the email page with translated text.

The example displays540,560are generated by a web browser (e.g.,304). The web documents in displays540and560are email pages displaying email messages, and the web document text is the body text of the email messages. The body text are displayed as representations of the email messages. The body text of each email message can be included in a respective text node in a DOM representation. Additional text can also be included, for example, the subject text of the email message.

Display560illustrates an email page displaying multiple email messages, e.g., an email conversation. For example, display560shows first, second and third email messages542,544and546, respectively, although only email message542is expanded to show its body text548. The original language (first language) of the body text in display560is Spanish.

InFIG. 5A, the body text of a first email message of the email messages to be translated is identified (502). The body text of a first email message (e.g.,542) of one or more displayed email messages can be identified as the body text of an active email message. For example, an active email message is an email message that is currently opened or otherwise selected, e.g., as indicated by a cursor position or other user inputs. With reference to display560, email message542is the active email message as it is expanded (e.g., open). The body text548can be identified by its respective text node. The web browser304and/or the client device302can, by use of the translation header element310, identify the body text to be translated.

For the body text of the first email message it is determined that the second language is different from the first language (504). The translation header element310can, for example, determine that the second language is different from the first language and display the translation header with the body text of the first email message. Display560shows the translation header550in a first display configuration with the body text548. The translation header text identifies the second language (e.g., specified language) as English, i.e., the language to which the Spanish text should be translated.

In some implementations, each expanded email message that includes body text not in the specified language can be displayed with a translation header. For example, if email messages544and546were expanded then each message could be displayed with a translation header if the respective body texts were not in the specified language. In some implementations, the translation header element310can also cause the web browser304to display a “Translate conversation” button553to cause all email messages in the email conversation to be displayed with translated text.

A request is sent to the translation server to translate the body text of only the first email message (506). The request is sent only if the second language is different from the first language. The web browser304can, for example, send a request to the translation server308to translate the body text of only the first email message. The request to translate the body text of the first email message can be a request to translate the subject of the first email message and the body of the first email message.

As indicated by the dashed process box508, the request of step506, optionally, is a request sent to the translation server without the body text of the first email message (508). The web browser304can, for example, send the request to the translation server308. The translation server can be in data communication (e.g., Remote Procedure Call protocol) with the email server handling the first email message. Because the email server distributed the first email message to the client device, it has access to the first email message or access to a copy of the first message. As such the request can include an identifier of the first email message, instead of the body text of the first email message. The identifier of the first email message can be resolved by the email server or the translation server to identify the first email message. The translation server can then translate the body text of the email message.

Translation data including translated body text of the first email message in the second language are received (510). The translation data include the translated body text of the first email message in the second language. The web browser304can, for example, receive the translation data from the translation server308.

The translated body text of the first email message and the body text of the other email messages are displayed (512). The web browser304can, for example, render the document including the body text of the first email message and the body text of the other email messages for display on the client device302. The body text of the other email messages may only include the subject of those email messages if the other email messages are in a collapsed display format. Display540shows the translated body text of the first email message (e.g., email message542) in the second language (i.e., English) and a collapsed display of the other email messages (e.g., email messages544and546).

As indicated by the dashed process boxes514and516, the display of step512, optionally, includes replacing, in the respective text node, the body text of the first email message in the first language with the translated body text of the first email message in the second language (514), and rendering the data structure having the translated body text included in the respective text node (516). The translation header element310can, for example, replace the body text in the first language with the translated body text in the second language in the respective text node and render the data structure having the translated body text included in the respective text node. Display540shows the translated body text548of the first email message542.

A request is sent for HTML data representing only the translated first email message (586). The HTML data can include, in addition to the body text of the first email message, for example, formatting information for the first email message, quoted text detection information for the first email message, and hiding information for the first email message. The web browser304can, for example, send a request for HTML data representing the translated first email message. In some implementations, HTML data for more than one email message can be requested.

The HTML data representing the translated first email message are received (588). The web browser304can, for example, receive the HTML data from the translation server308.

A portion of HTML data of the HTML email document corresponding to the untranslated first email message is replaced with the HTML data representing the translated first email message (590) For example, the translation header element310can replace the portion of HTML data of the email page corresponding to the untranslated first email message with the HTML of the translated first email message. The email page including the HTML of the translated first message can then be rendered by the web browser and displayed on the client device without a reload of the email page.

In still other implementations, instead of replacing the portion of HTML of the email page corresponding to the untranslated first message with the HTML of the translated first email message, the translation header element310can cause the web browser to render the HTML of the translated first email message for display on another portion of the displayed email page, such as in a message box, pop up box, tool tip or designated translation display area.

InFIG. 5C, the translation header550is displayed in a second display configuration. The second display configuration indicates that the portion of the document has been translated subsequent to a selection of the selectable option shown inFIG. 5B(e.g., the “Translate” button). The user can select “View original message” to view the message in its original form, or select “Change language” to translate the body text of the message to another language. If the latter option is selected, the original text of the email message is translated to a new language specified by the user, i.e., the process steps506-512above are re-executed to provide a translation of the original text to another different language. Thus the “Change Language” option causes the original text in the email message to be translated to the new language as opposed to the currently translated text (e.g., in English) to be translated to the new language.

FIG. 6is a flow diagram for an example method600for translating text in an HTML web page. The web document is an HTML web page, and is represented by a data structure. The data structure includes text nodes, each text node includes respective text of the HTML web page text.

A request with data including the text in the text nodes, as distinct objects, is sent to a translation server to translate the text (602). In some implementations the data is the DOM representation of the document or a copy of the DOM representation. In other implementations the data is sent in multiple segments, i.e., portions of the data are individually sent to the translation server. The web browser304can, for example, send a request to the translation server308to translate the text.

The text in the first language in the text nodes are replaced with corresponding translated text in the second language (604). The translated text are received from the translation server. For example, the translation header element310can replace text in the first language in the text nodes with corresponding translated text in the second language.

The data structure having the translated text in the text nodes is rendered (606). In some implementations the data structure is a DOM representation and the web browser renders the DOM representation to display the HTML web page with the translated text. The web browser304can, for example, render the data structure having the translated text in the text nodes.

A similar method of requesting and receiving translated text in a markup language document, such as the HTML web page of example method600, is described in U.S. patent application Ser. No. 61/161,309, entitled “WEB TRANSLATION WITH DISPLAY REPLACEMENT,” filed on Mar. 18, 2009, which is hereby incorporated by reference. However, other translation methods can also be used.

FIG. 7is a flow diagram for an example method700for providing a conditional translation header for translation of web document text in a web document, In general, example method can be implemented on a computer with a web browser.

A document comprising document text in a first language to be displayed on a client device is received (702). The web browser304can, for example, retrieve the document by using a hypertext transfer protocol (HTTP) for the client device302. In some implementations, the first language of the document text can be identified from a user input. For example, the user input can be from selection of a selectable option in the translation header displayed with the document text.

The document text of the document is displayed (704). The document can be a markup language document and the web browser304can render the markup language document for display on the client device302.

A second language to which the document text may be translated is identified (706). The second language can be a user's preferred language (e.g., the native language of the user). The user's preferred language can be determined, for example, from local settings on the client device (e.g.,302), such as web browser language settings, or from a cookie including data from past translations and the corresponding second languages (e.g., the data may indicate that a user requested translation to a certain second language). The translation header element310can, for example, identify the second language. In some implementations, the second language can be identified from a user input. For example, the user input can be from selection of a selectable option in the translation header.

The second language is determined to be different from the first language and, only in response to the determination, a translation header is displayed with the document text (708). The translation header includes text in the second language describing a selectable option in the translation header to translate document text from the first language to the second language. For example, the display of a translation header with document text is represented by display format120and shown in example display202.

In some implementations, the translation header is displayed simultaneously or substantially simultaneously with the display of the document text. In other implementations, the translation header disappears if, after a predefined time period, the user does not select a translation option.

The translation header element310can, for example, determine that the second language is different from the first language, and the web browser304can, for example, render the document including the translation header346and the document text312.

In response to a selection of the selectable option, a portion of the document text to be translated is identified (710). The portion of the document text can be the entire document text or less than the entire document text. In some implementations, the portion of document text is identified based on the type of document. For example, if the document is an HTML web page then the portion of the document text is all of the document text that can be translated (e.g., some document text may be identified as non-translatable by a “no translate” flag). In another example, if the document is an HTML email page then the portion of the document text is the portion of the document text corresponding to the active email message. In other implementations, the portion of document text is identified based on user input, such as highlighting a portion of the document text. The translation header element310and/or the web browser304can, for example, identify a portion of the document text to be translated.

A request from the client device is sent to a translation server to translate the portion of the document text from the first language to the second language (712). The web browser304can, for example, send a request to a translation server308to translate the portion of the document text from the first language to the second language. In some implementations, the request is sent in accord with the method described inFIGS. 5A and 5DIn other implementations, the request is sent in accord with the method described inFIG. 6.

Although the translation process performed by the translation server will often correctly identify the first language of the document text, as mentioned above, a user may specify the first language in the request to ensure that the first language of the document text is not misidentified. The translation header may provide a selectable option by which a user can designate the first language.

In response to the request, translation data including a corresponding translated portion of the document text in the second language is received (714). For example, the web browser304and/or the translation header element310can receive the translation data.

The translated portion of the document text is displayed (716). The web browser304can, for example, render the web document including the translated portion of the document text to display the translated portion of the document text on the client device302. For example, the display of a translation header with document text is represented by display format130and shown in example display204. In some implementations, the translated portion of the document text is displayed in accord with the method described inFIGS. 5A and 5D. In other implementations, the translated portion of the document text is displayed in accord with the method described inFIG. 6.

The document can contain a link to another document (e.g., a link to another web page). In some implementations, upon selection of the link, the translation header element310can cause the web browser to include data defining the second language in a request for the another document. The included data can cause the another document to be automatically displayed by the web browser in the second language. For example, the document text of a web page may have been translated from Spanish to English (e.g., by use of the translation element310and the process described above). If a link included in the web page is for a second page with text in Spanish, then upon selection of the link, the translation header element310can cause the web browser to append data (e.g., an identifier) to the request for the second web page indicating that translation of the second web page's text to English is requested. Given that the second web page includes a translation header element310(or another translation mechanism in the web page or web browser), the second web page will automatically be rendered by the web browser with its text translated to English.

In some implementations, the data appended to the request (or otherwise identified in the request) by the web browser is a query parameter (e.g., item (F), a URL parameter). For example, if the requested URL is “http://www.example.com,” then the web browser can append “#trans|target language” to the request, where “target language” is the second language. Thus the request would be, for example, “http://www.example.com? . . . #trans|target language.”

Although the translation header element (e.g.,310) has been discussed above as being included in the web document (e.g.,306), in some implementations the functionality of the translation header element is provided in an add-in component installed in the web browser304, such as a toolbar or gadget. Further, in other implementations, the functionality of the translation header element is provided in a bookmarklet to allow the above described features to be utilized for a web page without a translation element.