<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=link8onMouseOver="ShowTip(event, 'tt6', 'link8')"onMouseOut="HideTip('tt6')">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=link9onMouseOver="ShowTip(event, 'tt4', 'link9')"onMouseOut="HideTip('tt4')">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=link10onMouseOver="ShowTip(event, 'tt6', 'link10')"onMouseOut="HideTip('tt6')">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=link11onMouseOver="ShowTip(event, 'tt8', 'link11')"onMouseOut="HideTip('tt8')">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=link12onMouseOver="ShowTip(event, 'tt9', 'link12')"onMouseOut="HideTip('tt9')">resourcesEncoded</a> to disable this. If you disable this, make sure that your files are UTF-8 encoded.</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">resources</a></td><tdclass=SDescription>Associative array that maps from keys to values.</td></tr><trclass="SVariable SIndent2"><tdclass=SEntry><ahref="#mxResources.extension">extension</a></td><tdclass=SDescription>Specifies the extension used for language files. </td></tr><trclass="SVariable SIndent2 SMarked"><tdclass=SEntry><ahref="#mxResources.resourcesEncoded">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">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=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">isLanguageSupported</a></td><tdclass=SDescription>Hook for subclassers to disable support for a given language. </td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxResources.getDefaultBundle"id=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">getDefaultBundle</a></td><tdclass=SDescription>Hook for subclassers to return the URL for the special bundle. </td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxResources.getSpecialBundle"id=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">getSpecialBundle</a></td><tdclass=SDescription>Hook for subclassers to return the URL for the special bundle. </td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><a
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxResources.resources"></a>resources</h3><divclass=CBody><p>Associative array that maps from keys to values.</p></div></div></div>
<divclass="CVariable"><divclass=CTopic><h3class=CTitle><aname="mxResources.extension"></a>extension</h3><divclass=CBody><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><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><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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>isLanguageSupported: function(</td><tdclass=PParameternowrap>lan</td><tdclass=PAfterParametersnowrap>)</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=link13onMouseOver="ShowTip(event, 'tt10', 'link13')"onMouseOut="HideTip('tt10')">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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>getDefaultBundle: function(</td><tdclass=PParameternowrap>basename,</td></tr><tr><td></td><tdclass=PParameternowrap>lan</td><tdclass=PAfterParametersnowrap>)</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=link14onMouseOver="ShowTip(event, 'tt11', 'link14')"onMouseOut="HideTip('tt11')">extension</a> or null if <ahref="#mxResources.loadDefaultBundle"class=LVariableid=link15onMouseOver="ShowTip(event, 'tt12', 'link15')"onMouseOut="HideTip('tt12')">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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>getSpecialBundle: function(</td><tdclass=PParameternowrap>basename,</td></tr><tr><td></td><tdclass=PParameternowrap>lan</td><tdclass=PAfterParametersnowrap>)</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=link16onMouseOver="ShowTip(event, 'tt11', 'link16')"onMouseOut="HideTip('tt11')">extension</a> or null if <loadSpecialBundle> is false or lan equals <ahref="../mxClient-js.html#mxClient.defaultLanguage"class=LVariableid=link17onMouseOver="ShowTip(event, 'tt13', 'link17')"onMouseOut="HideTip('tt13')">mxClient.defaultLanguage</a>.</p><p>If <mxResources.languages> is not null and <ahref="../mxClient-js.html#mxClient.language"class=LVariableid=link18onMouseOver="ShowTip(event, 'tt8', 'link18')"onMouseOut="HideTip('tt8')">mxClient.language</a> contains a dash, then this method checks if <ahref="#mxResources.isLanguageSupported"class=LFunctionid=link19onMouseOver="ShowTip(event, 'tt1', 'link19')"onMouseOut="HideTip('tt1')">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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>add: function(</td><tdclass=PParameternowrap>basename,</td></tr><tr><td></td><tdclass=PParameternowrap>lan</td><tdclass=PAfterParametersnowrap>)</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.</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></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="mxResources.parse"></a>parse</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>parse: function(</td><tdclass=PParameternowrap>text</td><tdclass=PAfterParametersnowrap>)</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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>get: function(</td><tdclass=PParameternowrap>key,</td></tr><tr><td></td><tdclass=PParameternowrap>params,</td></tr><tr><td></td><tdclass=PParameternowrap>defaultValue</td><tdclass=PAfterParametersnowrap>)</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 prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>replacePlaceholders: function(</td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>params</td><tdclass=PAfterParametersnowrap>)</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=CToolTipid="tt1"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>isLanguageSupported: function(</td><tdclass=PParameternowrap>lan</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to disable support for a given language. </div></div><divclass=CToolTipid="tt2"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>getDefaultBundle: function(</td><tdclass=PParameternowrap>basename,</td></tr><tr><td></td><tdclass=PParameternowrap>lan</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to return the URL for the special bundle. </div></div><divclass=CToolTipid="tt3"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>getSpecialBundle: function(</td><tdclass=PParameternowrap>basename,</td></tr><tr><td></td><tdclass=PParameternowrap>lan</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Hook for subclassers to return the URL for the special bundle. </div></div><divclass=CToolTipid="tt4"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>add: function(</td><tdclass=PParameternowrap>basename,</td></tr><tr><td></td><tdclass=PParameternowrap>lan</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Adds the default and current language properties file for the specified basename. </div></div><divclass=CToolTipid="tt5"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>parse: function(</td><tdclass=PParameternowrap>text</td><tdclass=PAfterParametersnowrap>)</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="tt6"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>get: function(</td><tdclass=PParameternowrap>key,</td></tr><tr><td></td><tdclass=PParameternowrap>params,</td></tr><tr><td></td><tdclass=PParameternowrap>defaultValue</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the value for the specified resource key.</div></div><divclass=CToolTipid="tt7"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class="Prototype prettyprint"><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>replacePlaceholders: function(</td><tdclass=PParameternowrap>value,</td></tr><tr><td></td><tdclass=PParameternowrap>params</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Replaces the given placeholders with the given parameters.</div></div><divclass=CToolTipid="tt8"><divclass=CVariable>Defines the language of the client, eg. </div></div><divclass=CToolTipid="tt9"><divclass=CVariable>Specifies whether or not values in resource files are encoded with \u or percentage. </div></div><divclass=CToolTipid="tt10"><divclass=CVariable>Defines the optional array of all supported language extensions. </div></div><divclass=CToolTipid="tt11"><divclass=CVariable>Specifies the extension used for language files. </div></div><divclass=CToolTipid="tt12"><divclass=CVariable>Specifies if the default