30 lines
11 KiB
HTML
30 lines
11 KiB
HTML
<!DOCTYPE html PUBLIC ""
|
||
"">
|
||
<html><head><meta charset="UTF-8" /><title>scot.weft.i18n.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Internationalisation</span> <span class="project-version">1.0.5</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>internationalisation</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1 current"><a href="scot.weft.i18n.core.html"><div class="inner"><span>scot.weft.i18n.core</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="scot.weft.i18n.core.html#var-*config*"><div class="inner"><span>*config*</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-*default-language*"><div class="inner"><span>*default-language*</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-*resource-path*"><div class="inner"><span>*resource-path*</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-accept-language-grammar"><div class="inner"><span>accept-language-grammar</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-acceptable-languages"><div class="inner"><span>acceptable-languages</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-find-language-file-name"><div class="inner"><span>find-language-file-name</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-generate-accept-languages"><div class="inner"><span>generate-accept-languages</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-get-message"><div class="inner"><span>get-message</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-get-messages"><div class="inner"><span>get-messages</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-parse-accept-language-header"><div class="inner"><span>parse-accept-language-header</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-raw-get-messages"><div class="inner"><span>raw-get-messages</span></div></a></li><li class="depth-1"><a href="scot.weft.i18n.core.html#var-slurp-resource"><div class="inner"><span>slurp-resource</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">scot.weft.i18n.core</h1><div class="doc"><div class="markdown"><p>Internationalisation.</p></div></div><div class="public anchor" id="var-*config*"><h3>*config*</h3><h4 class="dynamic">dynamic</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Extensible configuration for i18n.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L32">view source</a></div></div><div class="public anchor" id="var-*default-language*"><h3>*default-language*</h3><h4 class="dynamic">dynamic</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>The default language to seek. Deprecated, prefer <code>(:default-language *config*)</code>.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L28">view source</a></div></div><div class="public anchor" id="var-*resource-path*"><h3>*resource-path*</h3><h4 class="dynamic">dynamic</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>The default path within the resources space on which translation files will be sought. Deprecated, prefer <code>(:resource-path *config*)</code>.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L23">view source</a></div></div><div class="public anchor" id="var-accept-language-grammar"><h3>accept-language-grammar</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Grammar for <code>Accept-Language</code> headers</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L37">view source</a></div></div><div class="public anchor" id="var-acceptable-languages"><h3>acceptable-languages</h3><div class="usage"><code>(acceptable-languages accept-language-header)</code></div><div class="doc"><div class="markdown"><p>Generate an ordered list of acceptable languages, most-preferred first.</p>
|
||
<ul>
|
||
<li><code>accept-language-header</code> should be the value of an RFC2616 <code>Accept-Language</code> header.</li>
|
||
</ul>
|
||
<p>Returns a list of maps as generated by <code>generate-accept-languages</code>, in descending order of preference.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L101">view source</a></div></div><div class="public anchor" id="var-find-language-file-name"><h3>find-language-file-name</h3><div class="usage"><code>(find-language-file-name language-spec resource-path)</code></div><div class="doc"><div class="markdown"><p>Find the name of a messages file on this resource path which matches this <code>language-spec</code>.</p>
|
||
<ul>
|
||
<li><code>language-spec</code> should be either a map as generated by <code>generate-accept-languages</code>, or else a string;</li>
|
||
<li><code>resource-path</code> should be the path name of the directory in which message files are stored, within the resources on the classpath.</li>
|
||
</ul>
|
||
<p>Returns the name of an appropriate file if any is found, else nil.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L131">view source</a></div></div><div class="public anchor" id="var-generate-accept-languages"><h3>generate-accept-languages</h3><div class="usage"><code>(generate-accept-languages parse-tree)</code></div><div class="doc"><div class="markdown"><p>From a <code>parse-tree</code> generated by the <code>language-specifier-grammar</code>, generate a list of maps each having a <code>:language</code> key, a <code>:preference</code> key and a <code>:qualifier</code> key.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L54">view source</a></div></div><div class="public anchor" id="var-get-message"><h3>get-message</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Return the message keyed by this <code>token</code> from the most acceptable messages collection<br />we have given this <code>accept-language-header</code>, if passed, or the current default language otherwise. If no message is found, return the token.</p>
|
||
<ul>
|
||
<li><code>token</code> should be a clojure keyword identifying the message to be retrieved;</li>
|
||
<li><code>accept-language-header</code> should be the value of an RFC2616 <code>Accept-Language</code> header;</li>
|
||
<li><code>resource-path</code> should be the fully-qualified path name of the directory in which message files are stored;</li>
|
||
<li><code>default-locale</code> should be a locale specifier to use if no acceptable locale can be identified.</li>
|
||
</ul></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L214">view source</a></div></div><div class="public anchor" id="var-get-messages"><h3>get-messages</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Return the most acceptable messages collection we have given this <code>accept-language-header</code></p>
|
||
<ul>
|
||
<li><code>accept-language-header</code> should be the value of an RFC2616 <code>Accept-Language</code> header;</li>
|
||
<li><code>resource-path</code> should be the fully-qualified path name of the directory in which message files are stored;</li>
|
||
<li><code>default-locale</code> should be a locale specifier to use if no acceptable locale can be identified.</li>
|
||
</ul>
|
||
<p>Returns a map of message keys to strings.; if no useable file is found, returns nil.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L202">view source</a></div></div><div class="public anchor" id="var-parse-accept-language-header"><h3>parse-accept-language-header</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Parse an <code>Accept-Language</code> header</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L50">view source</a></div></div><div class="public anchor" id="var-raw-get-messages"><h3>raw-get-messages</h3><div class="usage"><code>(raw-get-messages accept-language-header resource-path default-locale)</code></div><div class="doc"><div class="markdown"><p>Return the most acceptable messages collection we have given this <code>accept-language-header</code>. Do not use this function directly, use the memoized variant <code>get-messages</code>, as performance will be very much better.</p>
|
||
<ul>
|
||
<li><code>accept-language-header</code> should be the value of an RFC2616 <code>Accept-Language</code> header;</li>
|
||
<li><code>resource-path</code> should be the fully-qualified path name of the directory in which message files are stored;</li>
|
||
<li><code>default-locale</code> should be a locale specifier to use if no acceptable locale can be identified.</li>
|
||
</ul>
|
||
<p>Returns a map of message keys to strings; if no useable file is found, returns nil.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L161">view source</a></div></div><div class="public anchor" id="var-slurp-resource"><h3>slurp-resource</h3><div class="usage"><code>(slurp-resource name)</code></div><div class="doc"><div class="markdown"><p>Slurp the resource of this name and return its contents as a string; but if it doesn’t exist log the fact and return nil, rather than throwing an exception.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/internationalisation/blob/master/src/scot/weft/i18n/core.clj#L120">view source</a></div></div></div></body></html> |