Regenerated documentation - had failed to upversion README!

This commit is contained in:
Simon Brooke 2023-01-05 12:52:20 +00:00
parent 04780bfc02
commit 2d17d0b83b
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
3 changed files with 46 additions and 20 deletions

View file

@ -4,7 +4,7 @@
<p>A Clojure library designed to provide simple interationalisation of user-facing messages.</p>
<h2><a href="#usage" name="usage"></a>Usage</h2>
<p>To use this library in your project, add the following leiningen dependency:</p>
<pre><code>[org.clojars.simon_brooke/internationalisation "1.0.4"]
<pre><code>[org.clojars.simon_brooke/internationalisation "1.0.5"]
</code></pre>
<p>To use it in your namespace, require:</p>
<pre><code>[scot.weft.i18n.core :refer [get-message get-messages]]
@ -45,16 +45,15 @@
(get-message :pipe "de-DE" "i18n" "ru")
</code></pre>
<p>So how does this work? When one calls <code>(get-message token accept-language-header)</code>, how does it know where to find resources? The answer is that there are two dynamic variables:</p>
<p>So how does this work? When one calls <code>(get-message token accept-language-header)</code>, how does it know where to find resources? The answer is that there is a <code>*config*</code> map, with (currently) two significant keys:</p>
<ul>
<li><code>*resource-path*</code>, the default path within the resources space on which translation files will be sought. Initialised to <code>i18n</code>.</li>
<li><code>*default-language*</code>, the language tag for the language to use when no otherwise suitable language can be identified. Initialised to the default language of the runtime session, so this may well be different on your machine from someone elses running identical software.</li>
<li><code>:resource-path</code>, whose value should be a string representation of the default path within the resources space on which translation files will be sought. Initialised to <code>i18n</code>.</li>
<li><code>:default-language</code>, the language tag for the language to use when no otherwise suitable language can be identified. Initialised to the default language of the runtime session, so this may well be different on your machine from someone elses running identical software.</li>
</ul>
<p>Thus</p>
<pre><code class="clojure">(binding [*resource-path* "language-files"
*default-language* "en-CA"]
(get-message :pipe "en-GB;q=0.9, fr-FR")
)
<pre><code class="clojure">(binding [*config* {:resource-path "language-files"
:default-language "en-CA"}]
(get-message :pipe "en-GB;q=0.9, fr-FR"))
</code></pre>
<p>and</p>
<pre><code class="clojure">(get-message :pipe "en-GB;q=0.9, fr-FR" "language-files" "en-CA")
@ -79,9 +78,19 @@
{:pipe "Ceci n'est pas une pipe."}
</code></pre>
<h2><a href="#documentation" name="documentation"></a>Documentation</h2>
<p>Documentation may be generated by running</p>
<p>Documentation can be found here. It may be generated by running</p>
<pre><code>lein codox
</code></pre>
<h2><a href="#future-direction" name="future-direction"></a>Future direction</h2>
<p>Its likely that in future configuration will be extended</p>
<ol>
<li>To read per-language keys/messages from CSV files;</li>
<li>To read per-language keys/messages from database tables;</li>
<li>potentially, to read per-language keys/messages from other sources.</li>
</ol>
<p>Pull requests implementing any of these things will be welcomed.</p>
<h2><a href="#deprecated-features" name="deprecated-features"></a>Deprecated features</h2>
<p>There are still two dynamic configuration variables, <code>*default-language*</code> and <code>*resource-path*</code>, but these are now superceded by the <code>*config*</code> map, which is extensible. Consequently, if you are using these configuration variables in production, you should bind <code>*config*</code> to <code>nil</code>.</p>
<h2><a href="#license" name="license"></a>License</h2>
<p>Copyright © 2017 Simon Brooke</p>
<p>Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.</p></div></div></div></body></html>