Switching Between Languages Created in Scroll Translations

Translated content is not yet officially supported by Scroll Viewport, and it lacks some features. This situation may change in the future.

When Scroll Translations is enabled in a space, you can switch between languages. The selected language will always be present in the URL of the viewport.

For example:

Before

http://some.server.com/docs/my-page

After

http://some.server.com/docs/en/my-page

Enabling Scroll Translations Integration

The integration feature is not yet officially supported and must therefore be activated on a global level a single time. Then you must activate it for the individual viewports where you want to use it.

Activating the Integration

Info

Before activating the Scroll Translations integration you have to be logged in as System Administrator and the following Scroll add-ons versions must be installed:

Scroll Translations 1.6.5 (or higher)

Scroll Platform 2.7.5 (or higher)

Scroll Viewport 2.0 (or higher)

Open the following URL in a browser to enable the integration feature:

Switch the Language by using different Spaces

If you want to have a single space for each language, you can integrate a language switcher. The following code is based on the Switching Between Spaces Published by Scroll Versions recipe. As this is very similar to the recipe for switching between versions, take a look there for more background information.

// Put this within a script tag in a *.vm Velocity template (most probably where you define which JavaScript files you want to load)
var currentPathPrefix = '$viewport.link'.substring(contextPath.length + 1); // returns e.g. 'vprtEN' without a leading slash

Setup the HTML Select

// Add this to your desired JavaScript file and call the method while initialising
function spaceSelectSetup() {
// Preselect the HTML Select
$('#spaceSelect').val(currentPathPrefix);
// Add a change event handler which forwards the user to another viewport
$('#spaceSelect').change(function() {
// This is the Viewport path prefix written in <option value="pathPrefix">...</option>
var viewportPathPrefix = this.value;
// Preserve the current page where the user is. If he is on the home page, the string will be empty
var currentPagePath = location.pathname.substring(contextPath.length + currentPathPrefix.length + 1);
// Change the path of the URL and forward the user
location.pathname = contextPath + '/' + viewportPathPrefix + currentPagePath;
});
}

Using these snippets you can create a dropdown box and switch between different spaces with different languages.

Translated Templates

Sometimes the templates contain strings that need to be translated too. For example text in the header or footer should be translated.

To define translations enter the following code (usually in a separate, included template):

I18n of Confluence Macros

Currently Confluence Macros output static text in the language that the user has selected in Confluence. This means that the content of the viewport and the static text may have different languages. This is a known bug, tracked here: VPRT-476