> For the complete documentation index, see [llms.txt](https://developers.weglot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.weglot.com/cms/javascript/translate-iframe.md).

# Translate iframe

You have an iframe in your page and you need to translate it.

## Pre-required

You need to have the iframe control to **put Weglot snippet on the iframe**.

If you cannot put the snippet in the iframe, please [contact us](https://weglot.com/contact/enterprise/), we surely have another solutions for you.

## Setup

The parent window (main page) got the Weglot snippet to initialize it and there is a switcher on this page.

**1)** You have to put the same snippet in your iframe page, with the `hide_switcher` extra option to `true`, because you don't want another switcher in your iframe:

```markup
<script src="https://cdn.weglot.com/weglot.min.js"></script>
<script>
// In your iframe
Weglot.initialize({
    api_key: "wg_xxxx",
    hide_switcher: true // You already have a switcher in parent window
});
</script>
```

**2)** Add `translate_iframes` option with all CSS selectors in an array to select translated iframe in your page.

```markup
<script src="https://cdn.weglot.com/weglot.min.js"></script>
<script>
// In your parent window
Weglot.initialize({
    api_key: "wg_xxxx",
    translate_iframes: ["#iframe-id", ".my-little-iframe"]
});
</script>

```

Now, the parent window **can communicate** with your iframe, mainly **to switch language** when user select a new one.

## Tips

* You can add iframes selectors option all over your website, if selector is wrong or iframe doesn't exist, it doesn't matter
* Visiting a page with a translated iframe on it will count two visits on your dashboard (parent + iframe)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.weglot.com/cms/javascript/translate-iframe.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
