You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

projectdoc Toolbox

Generate a resource bundle with translations for a given set of keys.

Since
6.2
Path
rest/projectdoc/1/i18n/map

The service provides access to the translation service of the projectdoc Toolbox.

Basically the service accepts a list of I18N keys and returns the translated labels. The returned value is a simple map of key/value pairs. The key is the I18N key, the value the localized label for the key.

Parameters

keys

The comma-separated list of I18N keys.

If no key is provided the service returns with a BAD REQUEST (HTTP code 400).

locale

The optional locale to use. If not provided, the context of the call defines the locale.

Typically the value is not provided so that the locale provided of the user's context is used. In case a user needs to fetch localized information by a locale that is different from its default, supply a locale of the format accepted by toLocale(String).

If a locale is specified, but invalid, the service returns with a BAD REQUEST (HTTP code 400).

Default value: The locale specified by the calling user as default.

strict

The boolean flag allows to control whether or not the keys must be translated literally.

If this flag is set to false, the keys may be short versions where the prefix projectdoc.doctype.common. is missing for readability.

 

Users may only want to set this flag to true in case they need to actually access a label by a key that contains no dot.

Default value: false

Examples

JavaScript script

A typical usage scenario from a JavaScript script, where baseUrl points to the Confluence server hosting the REST service. The example assumes that jQuery is available in the context of this call.

Fetch resource bundle
var i18nResult = $.ajax({
  url: baseURL + "/rest/projectdoc/1/i18n/map.json?keys=title,spaceKey,name,shortDescription,tinyUrl",
  async: false,
  contentType: 'application/json'
}).responseText;

const i18n = JSON.parse(i18nResult);

Then access the localized labels like this:

Access resource bundle
const shortDescriptionLabel = i18n.shortDescription;

Bookmarklet

The Bookmarklets Extension provides a JavaScript function to create a synchronous call.

Using the Bookmarklets API
const i18n = PDBMLS.fetchI18n(baseUrl, ["spaceKey", "title", "doctype", "name", "shortDescription", "absoluteUrl", "projectdoc.imageUrl", "description", "projectdoc.doctype.resource.source", "projectdoc.address.website", "projectdoc.address.twitter"]);
  • No labels