Compare commits
No commits in common. "master" and "v1.0.4" have entirely different histories.
37
README.md
37
README.md
|
@ -6,7 +6,7 @@ A Clojure library designed to provide simple interationalisation of user-facing
|
||||||
|
|
||||||
To use this library in your project, add the following leiningen dependency:
|
To use this library in your project, add the following leiningen dependency:
|
||||||
|
|
||||||
[org.clojars.simon_brooke/internationalisation "1.0.5"]
|
[org.clojars.simon_brooke/internationalisation "1.0.4"]
|
||||||
|
|
||||||
To use it in your namespace, require:
|
To use it in your namespace, require:
|
||||||
|
|
||||||
|
@ -62,21 +62,21 @@ For example:
|
||||||
(get-message :pipe "de-DE" "i18n" "ru")
|
(get-message :pipe "de-DE" "i18n" "ru")
|
||||||
```
|
```
|
||||||
|
|
||||||
So how does this work? When one calls
|
So how does this work? When one calls `(get-message token accept-language-header)`, how does it know where to find resources? The answer is that there are two dynamic variables:
|
||||||
`(get-message token accept-language-header)`, how does it know where to find resources? The answer is that there is a `*config*` map, with (currently) two significant keys:
|
|
||||||
|
|
||||||
* `:resource-path`, whose value should be a string representation of the default
|
* `*resource-path*`, the default path within the resources space on which
|
||||||
path within the resources space on which translation files will be sought. Initialised to `i18n`.
|
translation files will be sought. Initialised to `i18n`.
|
||||||
* `:default-language`, the language tag for the language to use when no
|
* `*default-language*`, the language tag for the language to use when no
|
||||||
otherwise suitable language can be identified. Initialised to the default
|
otherwise suitable language can be identified. Initialised to the default
|
||||||
language of the runtime session, so this may well be different on your
|
language of the runtime session, so this may well be different on your
|
||||||
machine from someone elses running identical software.
|
machine from someone elses running identical software.
|
||||||
|
|
||||||
Thus
|
Thus
|
||||||
```clojure
|
```clojure
|
||||||
(binding [*config* {:resource-path "language-files"
|
(binding [*resource-path* "language-files"
|
||||||
:default-language "en-CA"}]
|
*default-language* "en-CA"]
|
||||||
(get-message :pipe "en-GB;q=0.9, fr-FR"))
|
(get-message :pipe "en-GB;q=0.9, fr-FR")
|
||||||
|
)
|
||||||
```
|
```
|
||||||
and
|
and
|
||||||
```clojure
|
```clojure
|
||||||
|
@ -116,27 +116,10 @@ In this project you will find two very simple example files, which should give y
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Documentation can be found here. It may be generated by running
|
Documentation may be generated by running
|
||||||
|
|
||||||
lein codox
|
lein codox
|
||||||
|
|
||||||
## Future direction
|
|
||||||
|
|
||||||
It's likely that in future configuration will be extended
|
|
||||||
|
|
||||||
1. To read per-language keys/messages from CSV files;
|
|
||||||
2. To read per-language keys/messages from database tables;
|
|
||||||
3. potentially, to read per-language keys/messages from other sources.
|
|
||||||
|
|
||||||
Pull requests implementing any of these things will be welcomed.
|
|
||||||
|
|
||||||
## Deprecated features
|
|
||||||
|
|
||||||
There are still two dynamic configuration variables, `*default-language*`
|
|
||||||
and `*resource-path*`, but these are now superceded by the `*config*` map,
|
|
||||||
which is extensible. Consequently, if you are using these configuration
|
|
||||||
variables in production, you should bind `*config*` to `nil`.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright © 2017 Simon Brooke
|
Copyright © 2017 Simon Brooke
|
||||||
|
|
37
doc/intro.md
37
doc/intro.md
|
@ -6,7 +6,7 @@ A Clojure library designed to provide simple interationalisation of user-facing
|
||||||
|
|
||||||
To use this library in your project, add the following leiningen dependency:
|
To use this library in your project, add the following leiningen dependency:
|
||||||
|
|
||||||
[org.clojars.simon_brooke/internationalisation "1.0.5"]
|
[org.clojars.simon_brooke/internationalisation "1.0.4"]
|
||||||
|
|
||||||
To use it in your namespace, require:
|
To use it in your namespace, require:
|
||||||
|
|
||||||
|
@ -62,21 +62,21 @@ For example:
|
||||||
(get-message :pipe "de-DE" "i18n" "ru")
|
(get-message :pipe "de-DE" "i18n" "ru")
|
||||||
```
|
```
|
||||||
|
|
||||||
So how does this work? When one calls
|
So how does this work? When one calls `(get-message token accept-language-header)`, how does it know where to find resources? The answer is that there are two dynamic variables:
|
||||||
`(get-message token accept-language-header)`, how does it know where to find resources? The answer is that there is a `*config*` map, with (currently) two significant keys:
|
|
||||||
|
|
||||||
* `:resource-path`, whose value should be a string representation of the default
|
* `*resource-path*`, the default path within the resources space on which
|
||||||
path within the resources space on which translation files will be sought. Initialised to `i18n`.
|
translation files will be sought. Initialised to `i18n`.
|
||||||
* `:default-language`, the language tag for the language to use when no
|
* `*default-language*`, the language tag for the language to use when no
|
||||||
otherwise suitable language can be identified. Initialised to the default
|
otherwise suitable language can be identified. Initialised to the default
|
||||||
language of the runtime session, so this may well be different on your
|
language of the runtime session, so this may well be different on your
|
||||||
machine from someone elses running identical software.
|
machine from someone elses running identical software.
|
||||||
|
|
||||||
Thus
|
Thus
|
||||||
```clojure
|
```clojure
|
||||||
(binding [*config* {:resource-path "language-files"
|
(binding [*resource-path* "language-files"
|
||||||
:default-language "en-CA"}]
|
*default-language* "en-CA"]
|
||||||
(get-message :pipe "en-GB;q=0.9, fr-FR"))
|
(get-message :pipe "en-GB;q=0.9, fr-FR")
|
||||||
|
)
|
||||||
```
|
```
|
||||||
and
|
and
|
||||||
```clojure
|
```clojure
|
||||||
|
@ -116,27 +116,10 @@ In this project you will find two very simple example files, which should give y
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Documentation can be found here. It may be generated by running
|
Documentation may be generated by running
|
||||||
|
|
||||||
lein codox
|
lein codox
|
||||||
|
|
||||||
## Future direction
|
|
||||||
|
|
||||||
It's likely that in future configuration will be extended
|
|
||||||
|
|
||||||
1. To read per-language keys/messages from CSV files;
|
|
||||||
2. To read per-language keys/messages from database tables;
|
|
||||||
3. potentially, to read per-language keys/messages from other sources.
|
|
||||||
|
|
||||||
Pull requests implementing any of these things will be welcomed.
|
|
||||||
|
|
||||||
## Deprecated features
|
|
||||||
|
|
||||||
There are still two dynamic configuration variables, `*default-language*`
|
|
||||||
and `*resource-path*`, but these are now superceded by the `*config*` map,
|
|
||||||
which is extensible. Consequently, if you are using these configuration
|
|
||||||
variables in production, you should bind `*config*` to `nil`.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright © 2017 Simon Brooke
|
Copyright © 2017 Simon Brooke
|
||||||
|
|
|
@ -2,19 +2,17 @@
|
||||||
{"scot/weft/i18n/core.clj":
|
{"scot/weft/i18n/core.clj":
|
||||||
[null, 1, null, null, null, null, null, null, null, null, null, null,
|
[null, 1, null, null, null, null, null, null, null, null, null, null,
|
||||||
null, null, null, null, null, null, null, null, null, null, null, 1,
|
null, null, null, null, null, null, null, null, null, null, null, 1,
|
||||||
null, null, null, null, 1, null, 1, null, 1, null, 1, null, null, 1,
|
null, null, null, null, 1, null, 1, null, 1, null, null, null, null,
|
||||||
null, null, null, null, null, null, null, null, null, null, null,
|
null, null, null, null, null, null, null, null, 1, null, 1, null, 1,
|
||||||
null, 1, null, 1, null, 1, null, null, null, null, null, true, 159,
|
null, null, null, null, null, true, 119, null, true, 119, 6, 16, 16,
|
||||||
null, true, 159, 11, 22, 22, 22, 9, null, 24, 24, null, 24, 24, 10,
|
16, 8, null, 18, 18, null, 18, 18, 9, null, 19, 19, 15, 15, null,
|
||||||
null, 25, 25, 20, 20, null, 20, 5, 26, 20, 20, 0, 0, null, 0, 20,
|
15, 4, 20, 15, 15, 0, 0, null, 0, 15, 15, null, 10, null, 0, 0,
|
||||||
20, null, 11, null, 0, 0, null, null, 1, null, null, null, null,
|
null, null, 1, null, null, null, null, null, null, null, null, 6, 6,
|
||||||
null, null, null, null, 10, 10, 10, 10, null, 10, 10, 0, null, null,
|
5, 5, null, 5, 5, 1, null, null, 1, null, null, null, 13, 13, null,
|
||||||
1, null, null, null, 24, 24, null, 11, null, null, null, 1, null,
|
7, null, null, null, 1, null, null, null, null, null, null, null,
|
||||||
null, null, null, null, null, null, null, null, null, 25, 25, 15,
|
null, null, null, 13, 13, 8, 8, 8, 13, 13, 13, 2, 11, 5, 5, 5, 5, 3,
|
||||||
15, 15, 25, 25, 25, 6, 19, 10, 10, 10, 10, 5, 5, 5, null, null, 1,
|
3, 3, null, null, 1, null, null, null, null, null, null, null, null,
|
||||||
null, null, null, null, null, null, null, null, null, null, null,
|
null, null, null, null, null, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3,
|
||||||
null, null, 9, 9, 9, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, true, 7,
|
3, 3, null, 1, null, null, 1, null, null, null, null, null, null,
|
||||||
null, 0, 0, 0, null, null, 2, 2, null, null, 1, null, null, null,
|
null, null, null, 1, null, 1, null, null, null, null, null, null,
|
||||||
null, null, null, null, null, null, 1, null, 1, null, null, null,
|
null, null, null, 1, 3, null, 1, null, 1]}}
|
||||||
null, null, null, null, null, null, null, 1, 8, 8, null, 7, 7, 7, 7,
|
|
||||||
null, 5, 5]}}
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><report><stats><packages value="1"/><methods value="413"/><srcfiles value="1"/><srclines value="106"/></stats><data><all name="total"><coverage type="class, %" value="0% (0/1)"/><coverage type="method, %" value="0% (0/1)"/><coverage type="block, %" value="82% (338/413)"/><coverage type="line, %" value="89% (94/106)"/><package name="scot.weft.i18n.core"><coverage type="class, %" value="0% (0/1)"/><coverage type="method, %" value="0% (0/1)"/><coverage type="block, %" value="82% (338/413)"/><coverage type="line, %" value="89% (94/106)"/></package></all></data></report>
|
<?xml version="1.0" encoding="UTF-8"?><report><stats><packages value="1"/><methods value="367"/><srcfiles value="1"/><srclines value="93"/></stats><data><all name="total"><coverage type="class, %" value="0% (0/1)"/><coverage type="method, %" value="0% (0/1)"/><coverage type="block, %" value="91% (333/367)"/><coverage type="line, %" value="92% (86/93)"/><package name="scot.weft.i18n.core"><coverage type="class, %" value="0% (0/1)"/><coverage type="method, %" value="0% (0/1)"/><coverage type="block, %" value="91% (333/367)"/><coverage type="line, %" value="92% (86/93)"/></package></all></data></report>
|
|
@ -16,26 +16,26 @@
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="scot/weft/i18n/core.clj.html">scot.weft.i18n.core</a></td><td class="with-bar"><div class="covered"
|
<td><a href="scot/weft/i18n/core.clj.html">scot.weft.i18n.core</a></td><td class="with-bar"><div class="covered"
|
||||||
style="width:81.84019370460048%;
|
style="width:90.73569482288828%;
|
||||||
float:left;"> 338 </div><div class="not-covered"
|
float:left;"> 333 </div><div class="not-covered"
|
||||||
style="width:18.159806295399516%;
|
style="width:9.264305177111716%;
|
||||||
float:left;"> 75 </div></td>
|
float:left;"> 34 </div></td>
|
||||||
<td class="with-number">81.84 %</td>
|
<td class="with-number">90.74 %</td>
|
||||||
<td class="with-bar"><div class="covered"
|
<td class="with-bar"><div class="covered"
|
||||||
style="width:88.67924528301887%;
|
style="width:92.47311827956989%;
|
||||||
float:left;"> 94 </div><div class="partial"
|
float:left;"> 86 </div><div class="partial"
|
||||||
style="width:2.830188679245283%;
|
style="width:2.150537634408602%;
|
||||||
float:left;"> 3 </div><div class="not-covered"
|
float:left;"> 2 </div><div class="not-covered"
|
||||||
style="width:8.49056603773585%;
|
style="width:5.376344086021505%;
|
||||||
float:left;"> 9 </div></td>
|
float:left;"> 5 </div></td>
|
||||||
<td class="with-number">91.51 %</td>
|
<td class="with-number">94.62 %</td>
|
||||||
<td class="with-number">235</td><td class="with-number">24</td><td class="with-number">106</td>
|
<td class="with-number">216</td><td class="with-number">23</td><td class="with-number">93</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>Totals:</td>
|
<tr><td>Totals:</td>
|
||||||
<td class="with-bar"></td>
|
<td class="with-bar"></td>
|
||||||
<td class="with-number">81.84 %</td>
|
<td class="with-number">90.74 %</td>
|
||||||
<td class="with-bar"></td>
|
<td class="with-bar"></td>
|
||||||
<td class="with-number">91.51 %</td>
|
<td class="with-number">94.62 %</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
024 "The default path within the resources space on which translation files
|
024 "The default path within the resources space on which translation files
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
025 will be sought. Deprecated, prefer `(:resource-path *config*)`."
|
025 will be sought."
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
026 "i18n")
|
026 "i18n")
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
028 (def ^:dynamic *default-language*
|
028 (def ^:dynamic *default-language*
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
029 "The default language to seek. Deprecated, prefer `(:default-language *config*)`."
|
029 "The default language to seek."
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
030 (-> (locale/get-default) locale/to-language-tag))
|
030 (-> (locale/get-default) locale/to-language-tag))
|
||||||
|
@ -97,617 +97,560 @@
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
031
|
031
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
|
||||||
032 (def ^:dynamic *config*
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
033 "Extensible configuration for i18n."
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="8 out of 8 forms covered">
|
|
||||||
034 {:default-language (-> (locale/get-default) locale/to-language-tag)
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
035 :resource-path "i18n"})
|
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
036
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
037 (def accept-language-grammar
|
032 (def accept-language-grammar
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
038 "Grammar for `Accept-Language` headers"
|
033 "Grammar for `Accept-Language` headers"
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
039 "HEADER := SPECIFIER | SPECIFIERS;
|
034 "HEADER := SPECIFIER | SPECIFIERS;
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
040 SPECIFIERS:= SPECIFIER | SPECIFIER SPEC-SEP SPECIFIERS;
|
035 SPECIFIERS:= SPECIFIER | SPECIFIER SPEC-SEP SPECIFIERS;
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
041 SPEC-SEP := #',\\s*';
|
036 SPEC-SEP := #',\\s*';
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
042 SPECIFIER := LANGUAGE-TAG | LANGUAGE-TAG Q-SEP Q-VALUE;
|
037 SPECIFIER := LANGUAGE-TAG | LANGUAGE-TAG Q-SEP Q-VALUE;
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
043 LANGUAGE-TAG := PRIMARY-TAG | PRIMARY-TAG '-' SUB-TAGS;
|
038 LANGUAGE-TAG := PRIMARY-TAG | PRIMARY-TAG '-' SUB-TAGS;
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
044 PRIMARY-TAG := #'[a-zA-Z]+';
|
039 PRIMARY-TAG := #'[a-zA-Z]+';
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
045 SUB-TAGS := SUB-TAG | SUB-TAG '-' SUB-TAGS;
|
040 SUB-TAGS := SUB-TAG | SUB-TAG '-' SUB-TAGS;
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
046 SUB-TAG := #'[a-zA-Z0-9]+';
|
041 SUB-TAG := #'[a-zA-Z0-9]+';
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
047 Q-SEP := #';\\s*q='
|
042 Q-SEP := #';\\s*q='
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
048 Q-VALUE := '1' | #'0.[0-9]+';")
|
043 Q-VALUE := '1' | #'0.[0-9]+';")
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
049
|
044
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
050 (def parse-accept-language-header
|
045 (def parse-accept-language-header
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
051 "Parse an `Accept-Language` header"
|
046 "Parse an `Accept-Language` header"
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
052 (insta/parser accept-language-grammar))
|
047 (insta/parser accept-language-grammar))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
053
|
048
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
054 (defn generate-accept-languages
|
049 (defn generate-accept-languages
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
055 "From a `parse-tree` generated by the `language-specifier-grammar`, generate
|
050 "From a `parse-tree` generated by the `language-specifier-grammar`, generate
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
056 a list of maps each having a `:language` key, a `:preference` key and a
|
051 a list of maps each having a `:language` key, a `:preference` key and a
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
057 `:qualifier` key."
|
052 `:qualifier` key."
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
058 {:doc/format :markdown}
|
053 {:doc/format :markdown}
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
059 [parse-tree]
|
054 [parse-tree]
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="partial" title="1 out of 2 forms covered">
|
<span class="partial" title="1 out of 2 forms covered">
|
||||||
060 (if
|
055 (if
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
061 (nil? parse-tree)
|
056 (nil? parse-tree)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
062 nil
|
057 nil
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="partial" title="2 out of 4 forms covered">
|
<span class="partial" title="2 out of 4 forms covered">
|
||||||
063 (case
|
058 (case
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
064 (first parse-tree)
|
059 (first parse-tree)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
065 :HEADER (generate-accept-languages (second parse-tree))
|
060 :HEADER (generate-accept-languages (second parse-tree))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
066 :SPECIFIERS (cons
|
061 :SPECIFIERS (cons
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
067 (generate-accept-languages (second parse-tree))
|
062 (generate-accept-languages (second parse-tree))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="6 out of 6 forms covered">
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
068 (when (>= (count parse-tree) 3)
|
063 (when (>= (count parse-tree) 3)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
069 (generate-accept-languages (nth parse-tree 3))))
|
064 (generate-accept-languages (nth parse-tree 3))))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
070 :SPEC-SEP nil
|
065 :SPEC-SEP nil
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
071 :SPECIFIER (assoc
|
066 :SPECIFIER (assoc
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
072 (generate-accept-languages (second parse-tree))
|
067 (generate-accept-languages (second parse-tree))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
073 :preference
|
068 :preference
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
074 (if
|
069 (if
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
075 (>= (count parse-tree) 3)
|
070 (>= (count parse-tree) 3)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
076 (generate-accept-languages (nth parse-tree 3))
|
071 (generate-accept-languages (nth parse-tree 3))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
077 1))
|
072 1))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
078 :LANGUAGE-TAG (if
|
073 :LANGUAGE-TAG (if
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
079 (>= (count parse-tree) 3)
|
074 (>= (count parse-tree) 3)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
080 (assoc
|
075 (assoc
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
081 (generate-accept-languages (second parse-tree))
|
076 (generate-accept-languages (second parse-tree))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
082 :qualifier
|
077 :qualifier
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
083 (generate-accept-languages (nth parse-tree 3)))
|
078 (generate-accept-languages (nth parse-tree 3)))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
084 (generate-accept-languages (second parse-tree)))
|
079 (generate-accept-languages (second parse-tree)))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="7 out of 7 forms covered">
|
<span class="covered" title="7 out of 7 forms covered">
|
||||||
085 :PRIMARY-TAG {:language (second parse-tree) :qualifier "*"}
|
080 :PRIMARY-TAG {:language (second parse-tree) :qualifier "*"}
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
086 :SUB-TAGS (if
|
081 :SUB-TAGS (if
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
087 (>= (count parse-tree) 3)
|
082 (>= (count parse-tree) 3)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-covered" title="0 out of 3 forms covered">
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
088 (str
|
083 (str
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-covered" title="0 out of 5 forms covered">
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
089 (generate-accept-languages (second parse-tree))
|
084 (generate-accept-languages (second parse-tree))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
090 "-"
|
085 "-"
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-covered" title="0 out of 5 forms covered">
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
091 (generate-accept-languages (nth parse-tree 3)))
|
086 (generate-accept-languages (nth parse-tree 3)))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
092 (generate-accept-languages (second parse-tree)))
|
087 (generate-accept-languages (second parse-tree)))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
093 :SUB-TAG (second parse-tree)
|
088 :SUB-TAG (second parse-tree)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
094 :Q-SEP nil
|
089 :Q-SEP nil
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
095 :Q-VALUE (read-string (second parse-tree))
|
090 :Q-VALUE (read-string (second parse-tree))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
096 ;; default
|
091 ;; default
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-covered" title="0 out of 2 forms covered">
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
097 (do
|
092 (do
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-covered" title="0 out of 16 forms covered">
|
<span class="not-covered" title="0 out of 16 forms covered">
|
||||||
098 (timbre/error "Unable to parse header.")
|
093 (timbre/error "Unable to parse header.")
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
099 nil))))
|
094 nil))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
095
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
096 (defn acceptable-languages
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
097 "Generate an ordered list of acceptable languages, most-preferred first.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
098
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
099 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header.
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
100
|
100
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
101 (defn acceptable-languages
|
101 Returns a list of maps as generated by `generate-accept-languages`, in descending order
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
102 "Generate an ordered list of acceptable languages, most-preferred first.
|
102 of preference."
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
103
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
104 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header.
|
103 {:doc/format :markdown}
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
105
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
106 Returns a list of maps as generated by `generate-accept-languages`, in descending order
|
104 [accept-language-header]
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
107 of preference."
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
108 {:doc/format :markdown}
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
109 [accept-language-header]
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
110 (let [parse-tree (parse-accept-language-header accept-language-header)]
|
105 (let [parse-tree (parse-accept-language-header accept-language-header)]
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
111 (if (vector? parse-tree)
|
106 (if (vector? parse-tree)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
112 (reverse
|
107 (reverse
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
113 (sort-by
|
108 (sort-by
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
114 :preference
|
109 :preference
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
115 (generate-accept-languages
|
110 (generate-accept-languages
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
116 parse-tree)))
|
111 parse-tree)))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-covered" title="0 out of 21 forms covered">
|
<span class="covered" title="21 out of 21 forms covered">
|
||||||
117 (timbre/error "Failed to parse Accept-Language header '" accept-language-header "':\n" (str parse-tree)))))
|
112 (timbre/error "Failed to parse Accept-Language header '" accept-language-header "':\n" (str parse-tree)))))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
118
|
113
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
119
|
114
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
120 (defn slurp-resource
|
115 (defn slurp-resource
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
121 "Slurp the resource of this name and return its contents as a string; but if it doesn't
|
116 "Slurp the resource of this name and return its contents as a string; but if it doesn't
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
122 exist log the fact and return nil, rather than throwing an exception."
|
117 exist log the fact and return nil, rather than throwing an exception."
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
123 [name]
|
118 [name]
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
124 (try
|
119 (try
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
125 (slurp (io/resource name))
|
120 (slurp (io/resource name))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
126 (catch Exception _
|
121 (catch Exception _
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="20 out of 20 forms covered">
|
<span class="covered" title="20 out of 20 forms covered">
|
||||||
127 (timbre/warn (str "Resource at " name " does not exist."))
|
122 (timbre/error (str "Resource at " name " does not exist."))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
128 nil)))
|
123 nil)))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
129
|
124
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
130
|
125
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
131 (defn find-language-file-name
|
126 (defn find-language-file-name
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
132 "Find the name of a messages file on this resource path which matches this `language-spec`.
|
127 "Find the name of a messages file on this resource path which matches this `language-spec`.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
128
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
129 * `language-spec` should be either a map as generated by `generate-accept-languages`, or
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
130 else a string;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
131 * `resource-path` should be the path name of the directory in which message files are stored,
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
132 within the resources on the classpath.
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
133
|
133
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
134 * `language-spec` should be either a map as generated by `generate-accept-languages`, or
|
134 Returns the name of an appropriate file if any is found, else nil."
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
135 else a string;
|
135 {:doc/format :markdown}
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
136 * `resource-path` should be the path name of the directory in which message files are stored,
|
136 [language-spec resource-path]
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
137 within the resources on the classpath.
|
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
138
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
139 Returns the name of an appropriate file if any is found, else nil."
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
140 {:doc/format :markdown}
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
141 [language-spec resource-path]
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
142 (let [file-path (when
|
137 (let [file-path (when
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
143 (string? language-spec)
|
138 (string? language-spec)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
144 (join
|
139 (join
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
145 java.io.File/separator
|
140 java.io.File/separator
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="6 out of 6 forms covered">
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
146 [resource-path (str language-spec ".edn")]))
|
141 [resource-path (str language-spec ".edn")]))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="6 out of 6 forms covered">
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
147 contents (when file-path (slurp-resource file-path))]
|
142 contents (when file-path (slurp-resource file-path))]
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
148 (cond
|
143 (cond
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
149 contents
|
144 contents
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
150 file-path
|
145 file-path
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
151 (map? language-spec)
|
146 (map? language-spec)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="5 out of 5 forms covered">
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
152 (or
|
147 (or
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
153 (find-language-file-name
|
148 (find-language-file-name
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="9 out of 9 forms covered">
|
<span class="covered" title="9 out of 9 forms covered">
|
||||||
154 (str (:language language-spec) "-" (:qualifier language-spec))
|
149 (str (:language language-spec) "-" (:qualifier language-spec))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
155 resource-path)
|
150 resource-path)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
156 (find-language-file-name
|
151 (find-language-file-name
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
157 (:language language-spec)
|
152 (:language language-spec)
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
158 resource-path)))))
|
153 resource-path)))))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
159
|
154
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
155
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
156 (defn raw-get-messages
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
157 "Return the most acceptable messages collection we have given this `accept-language-header`.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
158 Do not use this function directly, use the memoized variant `get-messages`, as performance
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
159 will be very much better.
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
160
|
160
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
161 (defn raw-get-messages
|
161 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
162 "Return the most acceptable messages collection we have given this `accept-language-header`.
|
162 * `resource-path` should be the fully-qualified path name of the directory in which
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
163 Do not use this function directly, use the memoized variant `get-messages`, as performance
|
163 message files are stored;
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
164 will be very much better.
|
164 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
165 identified.
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
165
|
166
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
166 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
167 Returns a map of message keys to strings; if no useable file is found, returns nil."
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
167 * `resource-path` should be the fully-qualified path name of the directory in which
|
168 {:doc/format :markdown}
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
168 message files are stored;
|
169 [^String accept-language-header ^String resource-path ^String default-locale]
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
169 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
170 identified.
|
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
171
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
172 Returns a map of message keys to strings; if no useable file is found, returns nil."
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
173 {:doc/format :markdown}
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
174 [^String accept-language-header ^String resource-path ^String default-locale]
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
175 (let [file-paths (remove
|
170 (let [file-path (first
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
|
||||||
176 empty?
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
177 (map
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
|
||||||
178 #(find-language-file-name % resource-path)
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
179 (acceptable-languages accept-language-header)))
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
180 default-path (join java.io.File/separator
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
181 [resource-path
|
171 (remove
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
172 nil?
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
173 (map
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
182 (str default-locale ".edn")])
|
174 #(find-language-file-name % resource-path)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
175 (acceptable-languages accept-language-header))))]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="20 out of 20 forms covered">
|
||||||
|
176 (timbre/debug (str "Found i18n file at '" file-path "'"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
177 (try
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
178 (read-string
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
179 (slurp-resource
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
180 (or
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
181 file-path
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
182 (join java.io.File/separator
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
183 [resource-path
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
184 (str default-locale ".edn")]))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
185 (catch Exception any
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="19 out of 19 forms covered">
|
||||||
|
186 (timbre/error (str "Failed to load internationalisation because " (.getMessage any)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
187 nil))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
188
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
189 (def get-messages
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
190 "Return the most acceptable messages collection we have given this `accept-language-header`
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
191
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
192 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
193 * `resource-path` should be the fully-qualified path name of the directory in which
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
194 message files are stored;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
195 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
196 identified.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
197
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
198 Returns a map of message keys to strings.; if no useable file is found, returns nil."
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
199 (memoize raw-get-messages))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
200
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
201 (def get-message
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
202 "Return the message keyed by this `token` from the most acceptable messages collection
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
203 we have given this `accept-language-header`.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
204
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
205 * `token` should be a clojure keyword identifying the message to be retrieved;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
206 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
207 * `resource-path` should be the fully-qualified path name of the directory in which
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
208 message files are stored;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
209 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
210 identified."
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
211 (fn ([^Keyword token ^String accept-language-header ^String resource-path ^String default-locale]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="7 out of 7 forms covered">
|
||||||
|
212 ((get-messages accept-language-header resource-path default-locale) token))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
213 ([^Keyword token ^String accept-language-header]
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="6 out of 6 forms covered">
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
183 paths (concat file-paths (list default-path))
|
214 (get-message token accept-language-header *resource-path* *default-language*))
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
|
||||||
184 text (first
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
185 (remove empty?
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
|
||||||
186 (map
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
|
||||||
187 slurp-resource
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
|
||||||
188 paths)))]
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
|
||||||
189 (if text
|
|
||||||
</span><br/>
|
|
||||||
<span class="partial" title="1 out of 2 forms covered">
|
|
||||||
190 (try
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
191 (read-string text)
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
192 (catch Exception any
|
215 ([^Keyword token]
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-covered" title="0 out of 16 forms covered">
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
193 (timbre/error "Failed to load internationalisation because "
|
216 (get-message token nil *resource-path* *default-language*))))
|
||||||
</span><br/>
|
|
||||||
<span class="not-covered" title="0 out of 2 forms covered">
|
|
||||||
194 (.getName (.getClass any))
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-covered" title="0 out of 1 forms covered">
|
|
||||||
195 (.getMessage any))
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
196 nil))
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
197 ;; else
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
198 (doall
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="17 out of 17 forms covered">
|
|
||||||
199 (timbre/error "No valid i18n files found, not even default. Tried" paths)
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
200 nil))))
|
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
201
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
|
||||||
202 (def get-messages
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
203 "Return the most acceptable messages collection we have given this `accept-language-header`
|
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
204
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
205 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
206 * `resource-path` should be the fully-qualified path name of the directory in which
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
207 message files are stored;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
208 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
209 identified.
|
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
210
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
211 Returns a map of message keys to strings.; if no useable file is found, returns nil."
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
212 (memoize raw-get-messages))
|
|
||||||
</span><br/>
|
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
|
||||||
213
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
|
||||||
214 (def get-message
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
215 "Return the message keyed by this `token` from the most acceptable messages collection
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
216 we have given this `accept-language-header`, if passed, or the current default language
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
217 otherwise. If no message is found, return the token.
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
218
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
219 * `token` should be a clojure keyword identifying the message to be retrieved;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
220 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
221 * `resource-path` should be the fully-qualified path name of the directory in which
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
222 message files are stored;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
223 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
224 identified."
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
|
||||||
225 (fn ([^Keyword token ^String accept-language-header ^String resource-path ^String default-locale]
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="8 out of 8 forms covered">
|
|
||||||
226 (let [message (token (get-messages accept-language-header resource-path default-locale))]
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="8 out of 8 forms covered">
|
|
||||||
227 (or message (name token))))
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
228 ([^Keyword token ^String accept-language-header]
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
229 (get-message token
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
|
||||||
230 accept-language-header
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="8 out of 8 forms covered">
|
|
||||||
231 (or (:resource-path *config*) *resource-path*)
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="8 out of 8 forms covered">
|
|
||||||
232 (or (:default-language *config*) *default-language*)))
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
233 ([^Keyword token]
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
|
||||||
234 (get-message token
|
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="8 out of 8 forms covered">
|
|
||||||
235 (or (:default-language *config*) *default-language*)))))
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<!DOCTYPE html PUBLIC ""
|
<!DOCTYPE html PUBLIC ""
|
||||||
"">
|
"">
|
||||||
<html><head><meta charset="UTF-8" /><title>Internationalisation 1.0.5</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 current"><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 "><a href="scot.weft.i18n.core.html"><div class="inner"><span>scot.weft.i18n.core</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name">Internationalisation</span> <span class="project-version">1.0.5</span></span></h1><h5 class="license">Released under the <a href="http://www.eclipse.org/legal/epl-v10.html">Eclipse Public License</a></h5><div class="doc"><p>Internationalisation library for Clojure.</p></div><h2>Installation</h2><p>To install, add the following dependency to your project or build file:</p><pre class="deps">[org.clojars.simon_brooke/internationalisation "1.0.5"]</pre><h2>Topics</h2><ul class="topics"><li><a href="intro.html">internationalisation</a></li></ul><h2>Namespaces</h2><div class="namespace"><h3><a href="scot.weft.i18n.core.html">scot.weft.i18n.core</a></h3><div class="doc"><div class="markdown"><p>Internationalisation.</p></div></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="scot.weft.i18n.core.html#var-*config*">*config*</a> </li><li> <a href="scot.weft.i18n.core.html#var-*default-language*">*default-language*</a> </li><li> <a href="scot.weft.i18n.core.html#var-*resource-path*">*resource-path*</a> </li><li> <a href="scot.weft.i18n.core.html#var-accept-language-grammar">accept-language-grammar</a> </li><li> <a href="scot.weft.i18n.core.html#var-acceptable-languages">acceptable-languages</a> </li><li> <a href="scot.weft.i18n.core.html#var-find-language-file-name">find-language-file-name</a> </li><li> <a href="scot.weft.i18n.core.html#var-generate-accept-languages">generate-accept-languages</a> </li><li> <a href="scot.weft.i18n.core.html#var-get-message">get-message</a> </li><li> <a href="scot.weft.i18n.core.html#var-get-messages">get-messages</a> </li><li> <a href="scot.weft.i18n.core.html#var-parse-accept-language-header">parse-accept-language-header</a> </li><li> <a href="scot.weft.i18n.core.html#var-raw-get-messages">raw-get-messages</a> </li><li> <a href="scot.weft.i18n.core.html#var-slurp-resource">slurp-resource</a> </li></ul></div></div></div></body></html>
|
<html><head><meta charset="UTF-8" /><title>Internationalisation 1.0.3-SNAPSHOT</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.3-SNAPSHOT</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 current"><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 "><a href="scot.weft.i18n.core.html"><div class="inner"><span>scot.weft.i18n.core</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name">Internationalisation</span> <span class="project-version">1.0.3-SNAPSHOT</span></span></h1><h5 class="license">Released under the <a href="http://www.eclipse.org/legal/epl-v10.html">Eclipse Public License</a></h5><div class="doc"><p>Internationalisation library for Clojure.</p></div><h2>Installation</h2><p>To install, add the following dependency to your project or build file:</p><pre class="deps">[org.clojars.simon_brooke/internationalisation "1.0.3-SNAPSHOT"]</pre><h2>Topics</h2><ul class="topics"><li><a href="intro.html">internationalisation</a></li></ul><h2>Namespaces</h2><div class="namespace"><h3><a href="scot.weft.i18n.core.html">scot.weft.i18n.core</a></h3><div class="doc"><div class="markdown"><p>Internationalisation.</p></div></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="scot.weft.i18n.core.html#var-*default-language*">*default-language*</a> </li><li> <a href="scot.weft.i18n.core.html#var-*resource-path*">*resource-path*</a> </li><li> <a href="scot.weft.i18n.core.html#var-accept-language-grammar">accept-language-grammar</a> </li><li> <a href="scot.weft.i18n.core.html#var-acceptable-languages">acceptable-languages</a> </li><li> <a href="scot.weft.i18n.core.html#var-find-language-file-name">find-language-file-name</a> </li><li> <a href="scot.weft.i18n.core.html#var-generate-accept-languages">generate-accept-languages</a> </li><li> <a href="scot.weft.i18n.core.html#var-get-message">get-message</a> </li><li> <a href="scot.weft.i18n.core.html#var-get-messages">get-messages</a> </li><li> <a href="scot.weft.i18n.core.html#var-parse-accept-language-header">parse-accept-language-header</a> </li><li> <a href="scot.weft.i18n.core.html#var-raw-get-messages">raw-get-messages</a> </li><li> <a href="scot.weft.i18n.core.html#var-slurp-resource">slurp-resource</a> </li></ul></div></div></div></body></html>
|
|
@ -1,10 +1,10 @@
|
||||||
<!DOCTYPE html PUBLIC ""
|
<!DOCTYPE html PUBLIC ""
|
||||||
"">
|
"">
|
||||||
<html><head><meta charset="UTF-8" /><title>internationalisation</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 current"><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 "><a href="scot.weft.i18n.core.html"><div class="inner"><span>scot.weft.i18n.core</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#internationalisation" name="internationalisation"></a>internationalisation</h1>
|
<html><head><meta charset="UTF-8" /><title>internationalisation</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.3-SNAPSHOT</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 current"><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 "><a href="scot.weft.i18n.core.html"><div class="inner"><span>scot.weft.i18n.core</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#internationalisation" name="internationalisation"></a>internationalisation</h1>
|
||||||
<p>A Clojure library designed to provide simple interationalisation of user-facing messages.</p>
|
<p>A Clojure library designed to provide simple interationalisation of user-facing messages.</p>
|
||||||
<h2><a href="#usage" name="usage"></a>Usage</h2>
|
<h2><a href="#usage" name="usage"></a>Usage</h2>
|
||||||
<p>To use this library in your project, add the following leiningen dependency:</p>
|
<p>To use this library in your project, add the following leiningen dependency:</p>
|
||||||
<pre><code>[org.clojars.simon_brooke/internationalisation "1.0.5"]
|
<pre><code>[org.clojars.simon_brooke/internationalisation "1.0.4"]
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<p>To use it in your namespace, require:</p>
|
<p>To use it in your namespace, require:</p>
|
||||||
<pre><code>[scot.weft.i18n.core :refer [get-message get-messages]]
|
<pre><code>[scot.weft.i18n.core :refer [get-message get-messages]]
|
||||||
|
@ -45,15 +45,16 @@
|
||||||
|
|
||||||
(get-message :pipe "de-DE" "i18n" "ru")
|
(get-message :pipe "de-DE" "i18n" "ru")
|
||||||
</code></pre>
|
</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 is a <code>*config*</code> map, with (currently) two significant keys:</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 are two dynamic variables:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<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>*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>*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>
|
</ul>
|
||||||
<p>Thus</p>
|
<p>Thus</p>
|
||||||
<pre><code class="clojure">(binding [*config* {:resource-path "language-files"
|
<pre><code class="clojure">(binding [*resource-path* "language-files"
|
||||||
:default-language "en-CA"}]
|
*default-language* "en-CA"]
|
||||||
(get-message :pipe "en-GB;q=0.9, fr-FR"))
|
(get-message :pipe "en-GB;q=0.9, fr-FR")
|
||||||
|
)
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<p>and</p>
|
<p>and</p>
|
||||||
<pre><code class="clojure">(get-message :pipe "en-GB;q=0.9, fr-FR" "language-files" "en-CA")
|
<pre><code class="clojure">(get-message :pipe "en-GB;q=0.9, fr-FR" "language-files" "en-CA")
|
||||||
|
@ -78,19 +79,9 @@
|
||||||
{:pipe "Ceci n'est pas une pipe."}
|
{:pipe "Ceci n'est pas une pipe."}
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<h2><a href="#documentation" name="documentation"></a>Documentation</h2>
|
<h2><a href="#documentation" name="documentation"></a>Documentation</h2>
|
||||||
<p>Documentation can be found here. It may be generated by running</p>
|
<p>Documentation may be generated by running</p>
|
||||||
<pre><code>lein codox
|
<pre><code>lein codox
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<h2><a href="#future-direction" name="future-direction"></a>Future direction</h2>
|
|
||||||
<p>It’s 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>
|
<h2><a href="#license" name="license"></a>License</h2>
|
||||||
<p>Copyright © 2017 Simon Brooke</p>
|
<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>
|
<p>Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.</p></div></div></div></body></html>
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
||||||
(defproject org.clojars.simon_brooke/internationalisation "1.0.5"
|
(defproject org.clojars.simon_brooke/internationalisation "1.0.4"
|
||||||
:cloverage {:output "docs/cloverage"
|
:cloverage {:output "docs/cloverage"
|
||||||
:codecov? true
|
:codecov? true
|
||||||
:emma-xml? true}
|
:emma-xml? true}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
;;;; This is a British English translation file.
|
;;;; This is a British English translation file.
|
||||||
|
|
||||||
{:pipe "This is not a pipe."}
|
{:pipe "This is not a pipe"}
|
||||||
|
|
|
@ -22,18 +22,13 @@
|
||||||
|
|
||||||
(def ^:dynamic *resource-path*
|
(def ^:dynamic *resource-path*
|
||||||
"The default path within the resources space on which translation files
|
"The default path within the resources space on which translation files
|
||||||
will be sought. Deprecated, prefer `(:resource-path *config*)`."
|
will be sought."
|
||||||
"i18n")
|
"i18n")
|
||||||
|
|
||||||
(def ^:dynamic *default-language*
|
(def ^:dynamic *default-language*
|
||||||
"The default language to seek. Deprecated, prefer `(:default-language *config*)`."
|
"The default language to seek."
|
||||||
(-> (locale/get-default) locale/to-language-tag))
|
(-> (locale/get-default) locale/to-language-tag))
|
||||||
|
|
||||||
(def ^:dynamic *config*
|
|
||||||
"Extensible configuration for i18n."
|
|
||||||
{:default-language (-> (locale/get-default) locale/to-language-tag)
|
|
||||||
:resource-path "i18n"})
|
|
||||||
|
|
||||||
(def accept-language-grammar
|
(def accept-language-grammar
|
||||||
"Grammar for `Accept-Language` headers"
|
"Grammar for `Accept-Language` headers"
|
||||||
"HEADER := SPECIFIER | SPECIFIERS;
|
"HEADER := SPECIFIER | SPECIFIERS;
|
||||||
|
@ -124,7 +119,7 @@
|
||||||
(try
|
(try
|
||||||
(slurp (io/resource name))
|
(slurp (io/resource name))
|
||||||
(catch Exception _
|
(catch Exception _
|
||||||
(timbre/warn (str "Resource at " name " does not exist."))
|
(timbre/error (str "Resource at " name " does not exist."))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,31 +167,23 @@
|
||||||
Returns a map of message keys to strings; if no useable file is found, returns nil."
|
Returns a map of message keys to strings; if no useable file is found, returns nil."
|
||||||
{:doc/format :markdown}
|
{:doc/format :markdown}
|
||||||
[^String accept-language-header ^String resource-path ^String default-locale]
|
[^String accept-language-header ^String resource-path ^String default-locale]
|
||||||
(let [file-paths (remove
|
(let [file-path (first
|
||||||
empty?
|
(remove
|
||||||
|
nil?
|
||||||
(map
|
(map
|
||||||
#(find-language-file-name % resource-path)
|
#(find-language-file-name % resource-path)
|
||||||
(acceptable-languages accept-language-header)))
|
(acceptable-languages accept-language-header))))]
|
||||||
default-path (join java.io.File/separator
|
(timbre/debug (str "Found i18n file at '" file-path "'"))
|
||||||
|
(try
|
||||||
|
(read-string
|
||||||
|
(slurp-resource
|
||||||
|
(or
|
||||||
|
file-path
|
||||||
|
(join java.io.File/separator
|
||||||
[resource-path
|
[resource-path
|
||||||
(str default-locale ".edn")])
|
(str default-locale ".edn")]))))
|
||||||
paths (concat file-paths (list default-path))
|
(catch Exception any
|
||||||
text (first
|
(timbre/error (str "Failed to load internationalisation because " (.getMessage any)))
|
||||||
(remove empty?
|
|
||||||
(map
|
|
||||||
slurp-resource
|
|
||||||
paths)))]
|
|
||||||
(if text
|
|
||||||
(try
|
|
||||||
(read-string text)
|
|
||||||
(catch Exception any
|
|
||||||
(timbre/error "Failed to load internationalisation because "
|
|
||||||
(.getName (.getClass any))
|
|
||||||
(.getMessage any))
|
|
||||||
nil))
|
|
||||||
;; else
|
|
||||||
(doall
|
|
||||||
(timbre/error "No valid i18n files found, not even default. Tried" paths)
|
|
||||||
nil))))
|
nil))))
|
||||||
|
|
||||||
(def get-messages
|
(def get-messages
|
||||||
|
@ -213,8 +200,7 @@
|
||||||
|
|
||||||
(def get-message
|
(def get-message
|
||||||
"Return the message keyed by this `token` from the most acceptable messages collection
|
"Return the message keyed by this `token` from the most acceptable messages collection
|
||||||
we have given this `accept-language-header`, if passed, or the current default language
|
we have given this `accept-language-header`.
|
||||||
otherwise. If no message is found, return the token.
|
|
||||||
|
|
||||||
* `token` should be a clojure keyword identifying the message to be retrieved;
|
* `token` should be a clojure keyword identifying the message to be retrieved;
|
||||||
* `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
* `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
||||||
|
@ -223,13 +209,8 @@
|
||||||
* `default-locale` should be a locale specifier to use if no acceptable locale can be
|
* `default-locale` should be a locale specifier to use if no acceptable locale can be
|
||||||
identified."
|
identified."
|
||||||
(fn ([^Keyword token ^String accept-language-header ^String resource-path ^String default-locale]
|
(fn ([^Keyword token ^String accept-language-header ^String resource-path ^String default-locale]
|
||||||
(let [message (token (get-messages accept-language-header resource-path default-locale))]
|
((get-messages accept-language-header resource-path default-locale) token))
|
||||||
(or message (name token))))
|
|
||||||
([^Keyword token ^String accept-language-header]
|
([^Keyword token ^String accept-language-header]
|
||||||
(get-message token
|
(get-message token accept-language-header *resource-path* *default-language*))
|
||||||
accept-language-header
|
|
||||||
(or (:resource-path *config*) *resource-path*)
|
|
||||||
(or (:default-language *config*) *default-language*)))
|
|
||||||
([^Keyword token]
|
([^Keyword token]
|
||||||
(get-message token
|
(get-message token nil *resource-path* *default-language*))))
|
||||||
(or (:default-language *config*) *default-language*)))))
|
|
|
@ -1,8 +1,7 @@
|
||||||
(ns ^{:doc "Tests for Internationalisation."
|
(ns ^{:doc "Tests for Internationalisation."
|
||||||
:author "Simon Brooke"} scot.weft.i18n.test.core
|
:author "Simon Brooke"} scot.weft.i18n.test.core
|
||||||
(:require [clojure.test :refer [deftest is testing]]
|
(:require [clojure.test :refer [deftest is testing]]
|
||||||
[scot.weft.i18n.core :refer [*config*
|
[scot.weft.i18n.core :refer [*default-language*
|
||||||
*default-language*
|
|
||||||
acceptable-languages
|
acceptable-languages
|
||||||
generate-accept-languages
|
generate-accept-languages
|
||||||
get-message
|
get-message
|
||||||
|
@ -207,7 +206,7 @@
|
||||||
(testing "Top level functionality"
|
(testing "Top level functionality"
|
||||||
(is
|
(is
|
||||||
(=
|
(=
|
||||||
"This is not a pipe."
|
"This is not a pipe"
|
||||||
(:pipe (get-messages "en-GB, fr-FR;q=0.9" "i18n" "en-GB"))))
|
(:pipe (get-messages "en-GB, fr-FR;q=0.9" "i18n" "en-GB"))))
|
||||||
(is
|
(is
|
||||||
(=
|
(=
|
||||||
|
@ -216,25 +215,9 @@
|
||||||
(is
|
(is
|
||||||
(= nil (get-messages "xx-XX;q=0.5, yy-YY" "i18n" "zz-ZZ"))
|
(= nil (get-messages "xx-XX;q=0.5, yy-YY" "i18n" "zz-ZZ"))
|
||||||
"If no usable file is found, an exception should not be thrown.")
|
"If no usable file is found, an exception should not be thrown.")
|
||||||
(binding [*config* (assoc *config* :default-language "fr-FR")]
|
(binding [*default-language* "en-GB"]
|
||||||
(is (= "Ceci n'est pas une pipe." (get-message :pipe)))
|
(is (= "This is not a pipe" (get-message :pipe)))
|
||||||
(is
|
(is
|
||||||
(=
|
(=
|
||||||
"This is not a pipe." (get-message :pipe "en-GB, fr-FR;q=0.9")))
|
"Ceci n'est pas une pipe." (get-message :pipe "en-GB;q=0.9, fr-FR")))
|
||||||
(is (= "это не труба." (get-message :pipe "de-DE" "i18n" "ru")))
|
(is (= "это не труба." (get-message :pipe "de-DE" "i18n" "ru"))))))
|
||||||
(is (= "froboz" (get-message :froboz)))))
|
|
||||||
(testing "Final fall through if no suitable language found"
|
|
||||||
(binding [*config* (assoc *config* :default-language "de-DE")]
|
|
||||||
;; there is no 'de-DE' language resource in the resources,
|
|
||||||
;; and that's exactly why we've chosen it for this test.
|
|
||||||
(is (= "pipe" (get-message :pipe)))))
|
|
||||||
(testing "Deprecated variables still work"
|
|
||||||
(binding [*config* nil
|
|
||||||
*default-language* "en-GB"]
|
|
||||||
(is (= "This is not a pipe." (get-message :pipe)))
|
|
||||||
(is
|
|
||||||
(= "Ceci n'est pas une pipe."
|
|
||||||
(get-message :pipe "en-GB;q=0.9, fr-FR"))))
|
|
||||||
(binding [*config* nil
|
|
||||||
*default-language* "ru"]
|
|
||||||
(is (= "это не труба." (get-message :pipe))))))
|
|
||||||
|
|
Loading…
Reference in a new issue