How to translate dynamic content?

In this article, you'll learn how to translate dynamic content for non-WordPress websites.

 

Please note that this feature is currently unavailable on WordPress. Translating dynamic content on WordPress websites can be achieved using PHP filters, as described in our Developer Documentation.

 

What is Dynamic Content?

 

Dynamic content on a website refers to elements that change in response to user interaction or in real-time updates. Examples of dynamic content include user-generated comments, real-time stock updates, or personalized greetings. Translating dynamic content can be a bit tricky, but this guide will simplify the process for you.

 

Steps to Translate Dynamic Content with Weglot

Access the Web Inspector

Navigate to the webpage you want to translate. Right-click on the page to display the contextual menu and select "Inspect" to open the web inspector panel of the browser Developer Tools. You can also display the Developer Tools by hitting the F12 key, or using Ctrl+Shift+I (Win/Linux), or Cmd+Option+I (macOS).

1. Right-click on the page to reveal a menu and select
Right-click on the page to reveal a menu and select "Inspect" to open the web inspector panel

Identify the Dynamic Element

In the Developer Tools, head to the Elements tab (Chrome) or Inspector tab (Firefox), and use the selector tool to hover over the area that isn't translated. This will highlight the element.

Inspector panel: use the selector tool to hover the element you want to translate
Inspector panel: use the selector tool to hover the element you want to translate.

Find the element's CSS selector

Once the element is highlighted, look for its class or ID in the Inspector panel and copy its name. You'll need to prefix it with a period (.) if it's a class name, or a hashtag (#) if it's an ID.

CSS selector: .class or #ID
CSS selector: here, the CSS selector can be .primary-text, as it is the class name of the element.

Alternatively, you can copy the CSS selector of an element from the Inspector panel by right-clicking on it and heading to Copy > Copy selector.

Right-click on the element and select Copy > Copy selector

Update Weglot Setting

Head over to your Weglot Dashboard. Then, choose your Weglot project and go to “Dynamic elements” in the left-side menu:

To add the dynamic content you'd like to translate, click the "Add a dynamic element" button. This will open up the "Add a dynamic element" box, where you can input the specific class or ID associated with the content.

Quick Tips

  1. Prefix a class name with a period (.) and an ID with a hashtag (#).
  2. You can also add a description to help you remember what the added selector translates to.
 

Save and Refresh

Click on "Add dynamic element". You might need to clear your browser cache and refresh the page to see the translated content. Don't hesitate to Hard-Refresh (Mac: cmd shift R (lowercase) / PC: ctrl F5) your website's page and check back in an incognito window if you don't notice the changes.

 

 

Give feedback about this article

Was this article helpful?