Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
titleExamples


Section
titleJavaScript 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.

Code Block
languagejs
titleFetch 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:

Code Block
languagejs
titleAccess resource bundle
const shortDescriptionLabel = i18n.shortDescription;



Section
titleBookmarklet

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

Code Block
languagejs
titleUsing 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"]);



...