<!-- saved from url=(0026)http://www.naturaldocs.org -->
<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=link6onMouseOver="ShowTip(event, 'tt5', 'link6')"onMouseOut="HideTip('tt5')">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=link7onMouseOver="ShowTip(event, 'tt3', 'link7')"onMouseOut="HideTip('tt3')">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=link8onMouseOver="ShowTip(event, 'tt5', 'link8')"onMouseOut="HideTip('tt5')">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=link9onMouseOver="ShowTip(event, 'tt6', 'link9')"onMouseOut="HideTip('tt6')">mxClient.language</a> for more information on specifying the default language or disabling all loading of resources.</p><p>Special characters</p><p>To use unicode characters use %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 <20> (&ouml;).</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.loadDefaultBundle">loadDefaultBundle</a></td><tdclass=SDescription>Specifies if the default file for a given basename should be loaded. </td></tr><trclass="SVariable SIndent2"><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.isBundleSupported">isBundleSupported</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=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">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=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">getSpecialBundle</a></td><tdclass=SDescription>Hook for subclassers to return the URL for the special bundle. </td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxResources.add"id=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">add</a></td><tdclass=SDescription>Adds the default and current language properties file for the specified basename. </td></tr><trclass="SFunction SIndent2 SMarked"><tdclass=SEntry><ahref="#mxResources.parse"id=link4onMouseOver="ShowTip(event, 'tt4', 'link4')"onMouseOut="HideTip('tt4')">parse</a></td><tdclass=SDescription>Parses the key, value pairs in the specified text and stores them as local resources.</td></tr><trclass="SFunction SIndent2"><tdclass=SEntry><ahref="#mxResources.get"id=link5onMouseOver="ShowTip(event, 'tt5', 'link5')"onMouseOut="HideTip('tt5')">get</a></td><tdclas
<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 ‘.properties’.</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.isBundleSupported"></a>isBundleSupported</h3><divclass=CBody><p>Hook for subclassers to disable support for a given language. This implementation always returns true.</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.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=link10onMouseOver="ShowTip(event, 'tt7', 'link10')"onMouseOut="HideTip('tt7')">extension</a> or null if <ahref="#mxResources.loadDefaultBundle"class=LVariableid=link11onMouseOver="ShowTip(event, 'tt8', 'link11')"onMouseOut="HideTip('tt8')">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=link12onMouseOver="ShowTip(event, 'tt7', 'link12')"onMouseOut="HideTip('tt7')">extension</a> or null if <loadSpecialBundle> is false or lan equals <ahref="../mxClient-js.html#mxClient.defaultLanguage"class=LVariableid=link13onMouseOver="ShowTip(event, 'tt9', 'link13')"onMouseOut="HideTip('tt9')">mxClient.defaultLanguage</a>.</p><p>If <mxResources.languages> is not null and <ahref="../mxClient-js.html#mxClient.language"class=LVariableid=link14onMouseOver="ShowTip(event, 'tt6', 'link14')"onMouseOut="HideTip('tt6')">mxClient.language</a> contains a dash, then this method checks if <isLanguageSupported> 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>
</div><!--Content-->
<divid=Footer><ahref="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
<divclass=CToolTipid="tt1"><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="tt2"><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="tt3"><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="tt4"><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="tt5"><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="tt6"><divclass=CVariable>Defines the language of the client, eg. </div></div><divclass=CToolTipid="tt7"><divclass=CVariable>Specifies the extension used for language files. </div></div><divclass=CToolTipid="tt8"><divclass=CVariable>Specifies if the default file for a given basename should be loaded. </div></div><divclass=CToolTipid="tt9"><divclass=CVariable>Defines the default language which is used in the common resource files. </div></div><!--END_ND_TOOLTIPS-->