The goal of our text parsing in Website Localizer (WL) is to group as many related phrases together into a single phrase, while still detecting shared elements like headers and footers granularly enough to be re-used across multiple pages. To accomplish this, we look for text grouped within specific HTML tags that typically signify all the text inside should be part of the same phrase/translation. For example, if we see a <section> tag with many <p> tags inside of it, we will group all the <p> tags inside the <section> tag as one phrase. When human translations are ordered, all of the text in the <section> will be translated together which increases context and accuracy. Here are the HTML tags that we will parse everything inside of as one phrase:
- <h1> through <h6>
- Any other text not in one of the above tags
When there is one of these tags within another tag, we use to the outermost tag when making the phrase.
If any text or HTML within a parsed phrase changes on the web page, we will detect it as a brand new phrase, which will require a new translation. This means that if one <p> tag within a <section> changes, that the entire <section> will require a new translation as the change in the <p> tag could affect the context of the entire <section>.
This can also cause what appear to be “duplicate” phrases when invalid HTML are corrected by some web browsers, but not others. Chrome is very good at correcting invalid HTML when it renders the page. Other browsers are not as good or do not correct invalid HTML at all. This can cause the same sentence to be rendered with one set of HTML tags in Chrome and another set of HTML tags in Safari. Because the HTML tags are different, this will be picked up as two phrases even though the text is the same. An easy way to find instances of this is to compare the source of a page within Chrome (right click on any open area of the page and choose View Page Source) to the HTML in the Chrome’s Inspector (right click on any open area of the page and choose Inspect). Common corrections are HTML tags that were not closed properly, special characters like & or © not using proper HTML entities and ® not having a <sup> tag wrapped around them.
Before embedding the Translate.js code on your web page, here is a handy checklist to ensure the highest quality translations and prevent easily correctable issues.
- Ensure your HTML is 100% valid which should ensure that browsers like Chrome do not make any corrections to it.
- Apply our notranslate tag to any section on the site that should not be translated. More details here.
- Wrap logical sections of content that should be grouped together as one phrase in the appropriate tag from the list above. The most common examples are:
- Ensuring navigation bars using a UL
- Wrapping <p> tags from a single article in <article> or tags
- Wrapping similar phrases of text that are not considered an article in <section> tags
- Populate your Glossary within your Translate.com account with any proper nouns or specific translations you already have.