<divid=Content><divclass="CClass"><divclass=CTopicid=MainTopic><h1class=CTitle><aname="mxResources"></a>mxResources</h1><divclass=CBody><p>Implements internationalization. You can provide any number of resource files on the server using the following format for the filename: name[-en].properties. The en stands for any lowercase 2-character language shortcut (eg. de for german, fr for french).</p><p>If the optional language extension is omitted, then the file is used as a default resource which is loaded in all cases. If a properties file for a specific language exists, then it is used to override the settings in the default resource. All entries in the file are of the form key=value. The values may then be accessed in code via <ahref="#mxResources.get"class=LFunctionid=link13onMouseOver="ShowTip(event, 'tt10', 'link13')"onMouseOut="HideTip('tt10')">get</a>. Lines without equal signs in the properties files are ignored.</p><p>Resource files may either be added programmatically using <ahref="#mxResources.add"class=LFunctionid=link14onMouseOver="ShowTip(event, 'tt8', 'link14')"onMouseOut="HideTip('tt8')">add</a> or via a resource tag in the UI section of the editor configuration file, eg:</p><blockquote><preclass="prettyprint"><mxEditor>
<resource basename="examples/resources/mxWorkflow"/></pre></blockquote><p>The above element will load examples/resources/mxWorkflow.properties as well as the language specific file for the current language, if it exists.</p><p>Values may contain placeholders of the form {1}...{n} where each placeholder is replaced with the value of the corresponding array element in the params argument passed to <ahref="#mxResources.get"class=LFunctionid=link15onMouseOver="ShowTip(event, 'tt10', 'link15')"onMouseOut="HideTip('tt10')">mxResources.get</a>. The placeholder {1} maps to the first element in the array (at index 0).</p><p>See <ahref="../mxClient-js.html#mxClient.language"class=LVariableid=link16onMouseOver="ShowTip(event, 'tt13', 'link16')"onMouseOut="HideTip('tt13')">mxClient.language</a> for more information on specifying the default language or disabling all loading of resources.</p><p>Lines that start with a # sign will be ignored.</p><p>Special characters</p><p>To use unicode characters, use the standard notation (eg. \u8fd1) or %u as a prefix (eg. %u20AC will display a Euro sign). For normal hex encoded strings, use % as a prefix, eg. %F6 will display a “o umlaut” (&ouml;).</p><p>See <ahref="#mxResources.resourcesEncoded"class=LVariableid=link17onMouseOver="ShowTip(event, 'tt3', 'link17')"onMouseOut="HideTip('tt3')">resourcesEncoded</a> to disable this. If you disable this, make sure that your files are UTF-8 encoded.</p><p>Asynchronous loading</p><p>By default, the core adds two resource files synchronously at load time. To load these files asynchronously, set <mxLoadResources> to false before loading mxClient.js and use <ahref="#mxResources.loadResources"class=LFunctionid=link18onMouseOver="ShowTip(event, 'tt12', 'link18')"onMouseOut="HideTip('tt12')">mxResources.loadResources</a> instead.</p><!--START_ND_SUMMARY--><divclass=Summary><divclass=STitle>Summary</div><divclass=SBorder><tableborder=0cellspacing=0cellpadding=0class=STable><trclass="SMain"><tdclass=SEntry><ahref="#mxResources">mxResources</a></td><tdclass=SDescription>Implements internationalization. </td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxResources.Variables">Variables</a></td><tdclass=SDescription></td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxResources.resources"id=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">resources</a></td><tdclass=SDescription>Object that maps from keys to values.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxResources.extension"id=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">extension</a></td><tdclass=SDescription>Specifies the extension used for language files. </td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxResources.resourcesEncoded"id=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">resourcesEncoded</a></td><tdclass=SDescription>Specifies whether or not values in resource files are encoded with \u or percentage. </td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxResources.loadDefaultBundle"id=link4onMouseOver="ShowTip(event, 'tt4', 'link4')"onMouseOut="HideTip('tt4')">loadDefaultBundle</a></td><tdclass=SDescription>Specifies if the default file for a given basename should be loaded. </td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxResources.loadDefaultBundle">loadDefaultBundle</a></td><tdclass=SDescription>Specifies if the specific language file file for a given basename should be loaded. </td></tr><trclass="SGroup SIndent1"><tdclass=SEntry><ahref="#mxResources.Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxResources.isLanguageSupported"id=link5onMouseOver="ShowTip(event, 'tt5', 'link5')"onMouseOut="HideTip('tt5')">isLanguageSupported</a></td><tdclass=SDescripti
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxResources.resources"></a>resources</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">resources: {}</td></tr></table></blockquote><p>Object that maps from keys to values.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxResources.extension"></a>extension</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">extension: mxResourceExtension</td></tr></table></blockquote><p>Specifies the extension used for language files. Default is <mxResourceExtension>.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxResources.resourcesEncoded"></a>resourcesEncoded</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">resourcesEncoded: false</td></tr></table></blockquote><p>Specifies whether or not values in resource files are encoded with \u or percentage. Default is false.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxResources.loadDefaultBundle"></a>loadDefaultBundle</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">loadDefaultBundle: true</td></tr></table></blockquote><p>Specifies if the default file for a given basename should be loaded. Default is true.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxResources.loadDefaultBundle"></a>loadDefaultBundle</h3><divclass=CBody><p>Specifies if the specific language file file for a given basename should be loaded. Default is true.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.isLanguageSupported"></a>isLanguageSupported</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>isLanguageSupported: function(</td><tdclass="PParameter prettyprint "nowrap>lan</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to disable support for a given language. This implementation returns true if lan is in <ahref="../mxClient-js.html#mxClient.languages"class=LVariableid=link19onMouseOver="ShowTip(event, 'tt14', 'link19')"onMouseOut="HideTip('tt14')">mxClient.languages</a>.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>lan</td><tdclass=CDLDescription>The current language.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.getDefaultBundle"></a>getDefaultBundle</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>getDefaultBundle: function(</td><tdclass="PParameter prettyprint "nowrap>basename,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>lan</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to return the URL for the special bundle. This implementation returns basename + <ahref="#mxResources.extension"class=LVariableid=link20onMouseOver="ShowTip(event, 'tt2', 'link20')"onMouseOut="HideTip('tt2')">extension</a> or null if <ahref="#mxResources.loadDefaultBundle"class=LVariableid=link21onMouseOver="ShowTip(event, 'tt4', 'link21')"onMouseOut="HideTip('tt4')">loadDefaultBundle</a> is false.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>basename</td><tdclass=CDLDescription>The basename for which the file should be loaded.</td></tr><tr><tdclass=CDLEntry>lan</td><tdclass=CDLDescription>The current language.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.getSpecialBundle"></a>getSpecialBundle</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>getSpecialBundle: function(</td><tdclass="PParameter prettyprint "nowrap>basename,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>lan</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Hook for subclassers to return the URL for the special bundle. This implementation returns basename + ‘_’ + lan + <ahref="#mxResources.extension"class=LVariableid=link22onMouseOver="ShowTip(event, 'tt2', 'link22')"onMouseOut="HideTip('tt2')">extension</a> or null if <loadSpecialBundle> is false or lan equals <ahref="../mxClient-js.html#mxClient.defaultLanguage"class=LVariableid=link23onMouseOver="ShowTip(event, 'tt15', 'link23')"onMouseOut="HideTip('tt15')">mxClient.defaultLanguage</a>.</p><p>If <mxResources.languages> is not null and <ahref="../mxClient-js.html#mxClient.language"class=LVariableid=link24onMouseOver="ShowTip(event, 'tt13', 'link24')"onMouseOut="HideTip('tt13')">mxClient.language</a> contains a dash, then this method checks if <ahref="#mxResources.isLanguageSupported"class=LFunctionid=link25onMouseOver="ShowTip(event, 'tt5', 'link25')"onMouseOut="HideTip('tt5')">isLanguageSupported</a> returns true for the full language (including the dash). If that returns false the first part of the language (up to the dash) will be tried as an extension.</p><p>If <mxResources.language> is null then the first part of the language is used to maintain backwards compatibility.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>basename</td><tdclass=CDLDescription>The basename for which the file should be loaded.</td></tr><tr><tdclass=CDLEntry>lan</td><tdclass=CDLDescription>The language for which the file should be loaded.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.add"></a>add</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>add: function(</td><tdclass="PParameter prettyprint "nowrap>basename,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>lan,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>callback</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Adds the default and current language properties file for the specified basename. Existing keys are overridden as new files are added. If no callback is used then the request is synchronous.</p><h4class=CHeading>Example</h4><p>At application startup, additional resources may be added using the following code:</p><blockquote><preclass="prettyprint">mxResources.add('resources/editor');</pre></blockquote><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>basename</td><tdclass=CDLDescription>The basename for which the file should be loaded.</td></tr><tr><tdclass=CDLEntry>lan</td><tdclass=CDLDescription>The language for which the file should be loaded.</td></tr><tr><tdclass=CDLEntry>callback</td><tdclass=CDLDescription>Optional callback for asynchronous loading.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.parse"></a>parse</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>parse: function(</td><tdclass="PParameter prettyprint "nowrap>text</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Parses the key, value pairs in the specified text and stores them as local resources.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.get"></a>get</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>get: function(</td><tdclass="PParameter prettyprint "nowrap>key,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>params,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>defaultValue</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the value for the specified resource key.</p><h4class=CHeading>Example</h4><p>To read the value for ‘welomeMessage’, use the following:</p><blockquote><preclass="prettyprint">var result = mxResources.get('welcomeMessage') || '';</pre></blockquote><p>This would require an entry of the following form in one of the English language resource files:</p><blockquote><preclass="prettyprint">welcomeMessage=Welcome to mxGraph!</pre></blockquote><p>The part behind the || is the string value to be used if the given resource is not available.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>key</td><tdclass=CDLDescription>String that represents the key of the resource to be returned.</td></tr><tr><tdclass=CDLEntry>params</td><tdclass=CDLDescription>Array of the values for the placeholders of the form {1}...{n} to be replaced with in the resulting string.</td></tr><tr><tdclass=CDLEntry>defaultValue</td><tdclass=CDLDescription>Optional string that specifies the default return value.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.replacePlaceholders"></a>replacePlaceholders</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>replacePlaceholders: function(</td><tdclass="PParameter prettyprint "nowrap>value,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>params</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Replaces the given placeholders with the given parameters.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>value</td><tdclass=CDLDescription>String that contains the placeholders.</td></tr><tr><tdclass=CDLEntry>params</td><tdclass=CDLDescription>Array of the values for the placeholders of the form {1}...{n} to be replaced with in the resulting string.</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.loadResources"></a>loadResources</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>loadResources: function(</td><tdclass="PParameter prettyprint "nowrap>callback</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Loads all required resources asynchronously. Use this to load the graph and editor resources if <mxLoadResources> is false.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>callback</td><tdclass=CDLDescription>Callback function for asynchronous loading.</td></tr></table></div></div></div>
<divclass=CToolTipid="tt1"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">resources: {}</td></tr></table></blockquote>Object that maps from keys to values.</div></div><divclass=CToolTipid="tt2"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">extension: mxResourceExtension</td></tr></table></blockquote>Specifies the extension used for language files. </div></div><divclass=CToolTipid="tt3"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">resourcesEncoded: false</td></tr></table></blockquote>Specifies whether or not values in resource files are encoded with \u or percentage. </div></div><divclass=CToolTipid="tt4"><divclass=CVariable><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><tdclass="prettyprint">loadDefaultBundle: true</td></tr></table></blockquote>Specifies if the default file for a given basename should be loaded. </div></div><divclass=CToolTipid="tt5"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>isLanguageSupported: function(</td><tdclass="PParameter prettyprint "nowrap>lan</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to disable support for a given language. </div></div><divclass=CToolTipid="tt6"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>getDefaultBundle: function(</td><tdclass="PParameter prettyprint "nowrap>basename,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>lan</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to return the URL for the special bundle. </div></div><divclass=CToolTipid="tt7"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>getSpecialBundle: function(</td><tdclass="PParameter prettyprint "nowrap>basename,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>lan</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to return the URL for the special bundle. </div></div><divclass=CToolTipid="tt8"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>add: function(</td><tdclass="PParameter prettyprint "nowrap>basename,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>lan,</td></tr><tr><td></td><tdclass="PParameter prettyprint "nowrap>callback</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Adds the default and current language properties file for the specified basename. </div></div><divclass=CToolTipid="tt9"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParameters prettyprint "nowrap>parse: function(</td><tdclass="PParameter prettyprint "nowrap>text</td><tdclass="PAfterParameters prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Parses the key, value pairs in the specified text and stores them as local resources.</div></div><divclass=CToolTipid="tt10"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass="PBeforeParametersprettyprint