Hide Table of Contents
What's New archive
Default API Strings

Various components in the ArcGIS JavaScript API use default strings that can be overridden. Examples of this are the text in the tool tip that appears when using drawing tools, text in various widgets like the attribute inspector or the text used to populate the alt attribute of a DOM node used in a widget like the Home Button.

To modify a string or strings used by the API, use Dojo's internationalization module to load esri/nls/jsapi and alias it as esriBundle. Once loaded, esriBundle is an object with all strings used by the API. Update the string in question before instantiating your widget and your new instance of a widget will use the string you specified. Here's an example that updates the Home Button widget's alt text to say "Full Extent" instead of "Default Extent".

require([
  "esri/map",
  "esri/dijit/HomeButton",
  "dojo/i18n!esri/nls/jsapi"
], function(
  Map, HomeButton, esriBundle
)  {
  esriBundle.widgets.homeButton.home.title = "Full Extent";

  var map = new Map("map", {
    center: [-56.049, 38.485],
    zoom: 3,
    basemap: "streets-vector"
  });

  var home = new HomeButton({
    map: map
  }, "HomeButton");
  home.startup();
});

If you're not sure where the string you want to modify lives, you can load the bundle and explore it using your browser's developer tools from any page that loads the JavaScript API. The simple create a map sample is one example. Run this code in your browser's console:

require(["dojo/i18n!esri/nls/jsapi"], function(b) { console.log(b); });

Then you have an object that you can explore to find the string you'd like to modify.

The legacy, pre-AMD way to do this using references to globals is no longer recommended.

Show Modal