Basic Translation Tutorial
Last updated
Was this helpful?
Last updated
Was this helpful?
This tutorial should take about 10 minutes. If you have any questions, click the purple live chat button in the bottom left corner or .
If you get stuck and cannot move forward, to see the final solution. Follow these docs if you need help Activating Mods. Once you've activated it, you'll find it in the Page Editor on the first panel, the .
Watch the video for a walkthrough of this tutorial.
Prefer the text version? Skip the video and keep reading!
Before getting started, you'll need:
You're ready to start the tutorial if your screen looks something like this.
At the end of each step, you'll see a 🏁 that shows you how to know if you're ready to move to the next step. There will be screenshots indicating how you should have configured the brick for that step.
For this mod, we'll use the Context Menu starter brick.
The Name field is the mod component in the first panel, the Mod Listings Panel.
The Title is the text that appears on the context menu. You may call it something like "Greek Translate" (or whatever language you'd like to translate to). You can also dynamically show the selected text by including %s
in the Title.
In the Menu context dropdown, choose selection
and remove all
by clicking the x after the text.
This ensures the context menu action only appears when you have text selected.
Not seeing your context menu? Check that you've highlighted text on the page!
Specify which sites you'd like to be able to run this mod on. By default, PixieBrix will set the current site, but if you want to run on any URL, click the All URLs option.
You can then remove the docs.pixiebrix.com
url by clicking the ABC at the end of the field and choosing X.
You're ready to move on to the next step if your brick looks like this:
You should also see an emoji appear when text is selected, and appearing when you right-click on the page:
Clicking that action runs the Brick Pipeline, so let's add more bricks.
Now that we can trigger our mod, we must tell it to do something. In this case, we want to connect to an API to translate the selected text.
Search for Translate and add this brick:
Click the integration field and select the Google Translate ✨ Built In option.
In the "Text to Translate" field, type @input.selectionText
to reference the text that was highlighted.
Set the Translate To Language to the language code you want to translate to. Want to stick with Greek? You can use `el`.
This will make it easier to reference later.
You're ready to move on to the next step if your brick looks like this:
You're ready to run your mod and check the API returns the expected response.
Highlight text on the webpage, and click the globe emoji to run the mod.
This is where you can view the response from the API. Click the > before @response
to open the object and view the response.
This response can be used in any bricks that come afterward, giving you a way to provide dynamic values to other bricks, such as displaying the response. We'll do this in the next step.
You're ready to move on if you can successfully see the translatedText response in the Data Panel of your sidebar, like the screenshot above.
If you have any errors, confirm you've configured your brick according to the screenshot in Step 2.
Lastly, we will add a brick to display our response in a sidebar.
You'll see that two bricks were added to your Brick Actions Panel:
Display Temporary Information
Render Document
In the brick Configuration Panel for the Display Temporary Information Brick, rename the Title to Translation
You can also choose to move the location from Sidebar to a Modal or Popover. We'll leave this as a Sidebar.
Click any element in the Preview panel to edit.
In this case, the element is a Header type. So, the configuration options include the text itself, which you can rename in the Title field.
Replace the text with "Translate" instead of "Example document".
You can also change the size of the header. There are other optional settings for styling and setting criteria to hide the element dynamically. You can leave these as is for this tutorial.
Now click the Example text element in the preview panel.
New configuration options appear for the Text element. Replace the Text value with the following:
Notice we can reference the output from the Translate brick by providing the variable path and wrapping it in {{ }}
to inject the value in hardcoded strings.
You're ready to move to the next step when your sidebar preview panel looks like this:
Your mod is built, so it's time to save and test it.
You can now close your Page Editor and test out your mod!
Select any text on the page (like this paragraph!), right-click, and then choose the Translate action.
You should see a sidebar with your translated text a moment later.
🎉 Congrats!! You just built a mod.
a PixieBrix account ()
the Page Editor open ()
basic understanding of the terms we use to reference sections of the Page Editor ()
To do this click the New Mod button in the top left of the Page Editor, then choose the Context Menu option. (?)
Once you click that, configuration options appear in the middle of your Page Editor, this is the .
If a title starts with an emoji, it will appear on the Visual Popover element when you select text.
In the , you'll see a + icon just below the Context Menu brick. Click the + button to open the Add a Brick modal.
You might have noticed some checkmarks appear next to brick in your (second panel in the Page Editor). This lets you know your steps succeeded.
Confirm you have selected the Translate brick (it will have a blue background in the Brick Actions Panel), then confirm you have selected the Output tab on the (last panel on the right).
Click the + button below the HTTP Response brick in the and search for the Display Temporary Information brick. Hover over it, then click the blue Add button.
Now, click the Render Document brick to style the Sidebar. Once you click the Render Document brick in the Brick Actions Panel, you'll see a preview appear on the far right panel (the )
Click the Example document text on the Preview Panel, and the middle will display options for modifying that element.
On the first panel on the left, the , click the Save icon on your translate mod.
If it's not working, you can to see how it's meant to be structured, and compare your build to the template mod. You can also or click the live chat button in the bottom left corner of this page.