Smartling's Context Capture Chrome Extension
Smartling Account Owners and Project Managers can use the Chrome Context Capture Extension to capture visual context from webpages.
The Chrome Context Capture Extension is an add-on for the Chrome browser that captures dynamic HTML context for a web application as you browse. Any content you can display in a browser can be contextualized this way. You can also use browser automation software such as Selenium to automate context capture, or simply provide your sitemap and have the extension crawl your site.
Only use the Chrome extension on source language sites. For example, if your primary web site is "smartlinghotels.com" and the Spanish version is "es.smartlinghotels.com", only use the extension on "www.smartlinghotels.com".
- Install the Chrome Content Capture extension via the Chrome Store. Once the extension is installed, you should have the Smartling Context Capture icon in your browser toolbar.
- Browse to the page you want to contextualize. Strings on the page should match strings already uploaded to a Smartling project.
- Click the Context Capture icon. The extension will capture the current state of the page at the moment you click. If you want to capture a dynamic element such as a modal dialog, make sure that element is displaying on the page before you click the toolbar button.
- Login from the "Click here to Log In" button.
- From the drop-down, select the destination project in your Smartling account for the snapshot. You can preview the snapshot by clicking Preview.
- Click Send.
Smartling sends the context to the selected project. If it matches uploaded strings, Smartling displays the snapshot of the entire page to translators in the CAT Tool. The string matches will highlight for translators and update the context with their translation in real-time as they translate. Translators can toggle between viewing their translation in context or revert back to viewing the source strings in context by clicking the gear icon on the context panel.
Targeting Specific Strings
By default, a Chrome Context snapshot will capture the entire page at that moment, making the full webpage visible in the context panel in the CAT Tool, but only the string matches will highlight for Translator. You can use the string selection tool to target specific strings for contextualization and exclude areas of the webpage for which the snapshot will not provide good context. For example, if you want to capture context for a modal dialog in the middle of the page, but exclude visibility of anything outside that dialog, use the selection tool to target only the dialog and its strings.
Using this function will overwrite any existing context for your selected strings.
To use string selection:
- Follow the instructions for taking a snapshot, but before sending, click Select strings.
- In the snapshot preview, select strings or regions of the page with the selection tool.
If you select a region, all visible strings within that region will be included in your selection. You can also click Select Whole Page.
- When you have finished making your selection, click Send.
Improve Context Matching With Instrumented Files
Using an instrumented resource file in a test environment can help you get faster and more accurate context matching with the Chrome Context Capture Extension.
Instrumented files are a modified version of the original file with each string wrapped in invisible unicode characters generated from the string’s hashcode. On the page, strings will look exactly the same, but The Chrome Context Capture Extension can match them exactly with their equivalent strings in a Smartling project. The effects of using an instrumented file include:
- Context matching completes faster.
- Each variant of a string will match to its correct context.
- If the Chrome Context Capture Extension detects at least one instrumented string on a page, only instrumented strings will be matched. This is helpful for targeting context matching to specific strings, especially when using automation.
To use instrumented files:
- From Content > Files (or, in the New Experience, the Files tab in your project), download the instrumented files containing the strings you want to contextualize. You can also download instrumented files via the API.
- Deploy your web application using the instrumented files.
- Use the Chrome Context Capture Extension to take context snapshots in your test environment.
Overwrite Existing Context
By default, the Smartling Chrome Content Capture Extension will not override existing context for a string. To replace context for a string, either use the Reset Context action in the list view before using the Extension, or use the Select Strings function to override existing context for selected strings.
You can also control context overwrite in the Chrome Context Capture Extension by marking your site code with Smartling HTML classes. This is especially useful when automating. To override context for an entire page, add the two classes “sl-override-context sl-translate” to the page’s HTML tag.
To override context for an entire page:
Add the two classes
sl-translate to the page’s HTML tag.
To override context for specific elements on the page:
- Add the
sl-notranslateclass to the HTML tag of the page.
- Add the two classes
sl-translateto the elements you want to override context for. Any nested child elements will also be overwritten.
The History function displays a list of context snapshots and statistics about the number of successful string matches.
- From the Context Capture toolbar button, click the Gear icon > History. The Feedback dialog displays a list of context snapshots with information such as the number of strings updated and matched. Note, that a snapshot will only be created if context has been updated for at least one string.
- If your submission matches strings in the project, clicking the view link displays the new context snapshot.
- Clicking Clear History allows you to clear the history log. This will not affect context already in the Dashboard.
Setting a Keyboard Shortcut
Google Chrome has a Keyboard Shortcut feature that allows you to set up shortcuts for Chrome browser extensions. This is useful if you want to take a snapshot of content in difficult-to-expose elements of a page, such as drop-down hover menus.
In the Chrome browser, right-click the Context Capture icon > Manage Extensions. On the top-left of the page, click Extensions > Keyboard Shortcuts.
In the Smartling Context Capture section, hold down CTRL, ALT, or Command + the key (letter) you wish to use for your shortcut, eg: Command + Shift + S.
- In Chrome, right-click the Chrome Context Capture Extension and select Options.
- There's also the ability to enable Autocapture. To use this feature, once you select Options, hold down the Shift + Alt/Option + A keys. You'll also need to enter an API key and a UID. To retrieve these, go to Smartling > Projects > API. For the API key field, enter the Smartling API key. For the UID field, enter the Project ID.
- Follow the procedure for Taking a Snapshot
Capturing Context on iFrame Sites
Iframes are windows within a webpage that contain a separate web page, such as a web form. A regular snapshot using the Chrome Context Capture Extension will not capture content within an iframe.
Right-click on the iframe window and from the drop-down menu, select Capture iframe, then follow the procedure to Capture a Snapshot.
If you use browser automation software - such as Selenium, PhantomJS - for testing purposes, you can set up the Chrome Context Capture Extension to integrate with your existing test scripts and take a snapshot and any point in a script.
- In Chrome, right-click the Chrome Context Capture Extension and select Options.
- Check Detect Automation.
- To take a snapshot during automation, add this code to your script, substituting your Project ID and API Key.
/* snapshot is submitted, move on */
The Chrome Context Capture Extension can be automated to capture context for an entire website. The Automation Tool is only available for Application Resource Files projects.
By default the Chrome Context Capture Extension will not override existing context.
- In Chrome, navigate to Chrome > Preferences > Extensions and click Options.
- Select Automation Tool.
- Drag your site’s sitemap.xml file into the marked area.
In your sitemap.xml file you can create a
<url-list>node populated with a list of URLs you wish to contextualize. You can also preload your Project UID and API key by adding this code at the top of your sitemap:
<apikey>#######</apikey>You can download a custom sitemap template here.
4. Set up the automation tool:
- Project UID: Can be found on the Dashboard at Project Settings > API.
- API Key: Can be found on the Dashboard at Project Settings > API.
- URL Filter: Filters URLs by text. Snapshots will only be taken of URLs matching your filter text.
- Test Mode: If checked, the Chrome Context Capture Extension will crawl the selected urls, but will not take snapshots. You can also click test next to any URL to view a preview snapshot for that URL.
5. Click Start. The Automation Tool will capture a snapshot of each selected URL and match the snapshots to any matching strings in your project.