Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
|
2d17d0b83b | ||
|
04780bfc02 | ||
|
196b489256 | ||
|
d515763cda | ||
|
d1c96732b5 | ||
|
aadf7f46a0 | ||
|
341462a903 | ||
|
86a57fca93 |
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.4"]
|
[org.clojars.simon_brooke/internationalisation "1.0.5"]
|
||||||
|
|
||||||
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 `(get-message token accept-language-header)`, how does it know where to find resources? The answer is that there are two dynamic variables:
|
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 is a `*config*` map, with (currently) two significant keys:
|
||||||
|
|
||||||
* `*resource-path*`, the default path within the resources space on which
|
* `:resource-path`, whose value should be a string representation of the default
|
||||||
translation files will be sought. Initialised to `i18n`.
|
path within the resources space on which 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 [*resource-path* "language-files"
|
(binding [*config* {: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,10 +116,27 @@ In this project you will find two very simple example files, which should give y
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Documentation may be generated by running
|
Documentation can be found here. It 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.4"]
|
[org.clojars.simon_brooke/internationalisation "1.0.5"]
|
||||||
|
|
||||||
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 `(get-message token accept-language-header)`, how does it know where to find resources? The answer is that there are two dynamic variables:
|
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 is a `*config*` map, with (currently) two significant keys:
|
||||||
|
|
||||||
* `*resource-path*`, the default path within the resources space on which
|
* `:resource-path`, whose value should be a string representation of the default
|
||||||
translation files will be sought. Initialised to `i18n`.
|
path within the resources space on which 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 [*resource-path* "language-files"
|
(binding [*config* {: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,10 +116,27 @@ In this project you will find two very simple example files, which should give y
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Documentation may be generated by running
|
Documentation can be found here. It 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,17 +2,19 @@
|
||||||
{"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, null, null, null,
|
null, null, null, null, 1, null, 1, null, 1, null, 1, null, null, 1,
|
||||||
null, null, null, null, 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, true, 119, null, true, 119, 6, 16, 16,
|
null, 1, null, 1, null, 1, null, null, null, null, null, true, 159,
|
||||||
16, 8, null, 18, 18, null, 18, 18, 9, null, 19, 19, 15, 15, null,
|
null, true, 159, 11, 22, 22, 22, 9, null, 24, 24, null, 24, 24, 10,
|
||||||
15, 4, 20, 15, 15, 0, 0, null, 0, 15, 15, null, 10, null, 0, 0,
|
null, 25, 25, 20, 20, null, 20, 5, 26, 20, 20, 0, 0, null, 0, 20,
|
||||||
null, null, 1, null, null, null, null, null, null, null, null, 6, 6,
|
20, null, 11, null, 0, 0, null, null, 1, null, null, null, null,
|
||||||
5, 5, null, 5, 5, 1, null, null, 1, null, null, null, 13, 13, null,
|
null, null, null, null, 10, 10, 10, 10, null, 10, 10, 0, null, null,
|
||||||
7, null, null, null, 1, null, null, null, null, null, null, null,
|
1, null, null, null, 24, 24, null, 11, null, null, null, 1, null,
|
||||||
null, null, null, 13, 13, 8, 8, 8, 13, 13, 13, 2, 11, 5, 5, 5, 5, 3,
|
null, null, null, null, null, null, null, null, null, 25, 25, 15,
|
||||||
3, 3, null, null, 1, null, null, null, null, null, null, null, null,
|
15, 15, 25, 25, 25, 6, 19, 10, 10, 10, 10, 5, 5, 5, null, null, 1,
|
||||||
null, null, null, null, null, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3,
|
null, null, null, null, null, null, null, null, null, null, null,
|
||||||
3, 3, null, 1, null, null, 1, null, null, null, null, null, null,
|
null, null, 9, 9, 9, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, true, 7,
|
||||||
null, null, null, 1, 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, 3, null, 1, null, 1]}}
|
null, null, null, null, null, null, 1, null, 1, null, null, null,
|
||||||
|
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="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>
|
<?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>
|
|
@ -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:90.73569482288828%;
|
style="width:81.84019370460048%;
|
||||||
float:left;"> 333 </div><div class="not-covered"
|
float:left;"> 338 </div><div class="not-covered"
|
||||||
style="width:9.264305177111716%;
|
style="width:18.159806295399516%;
|
||||||
float:left;"> 34 </div></td>
|
float:left;"> 75 </div></td>
|
||||||
<td class="with-number">90.74 %</td>
|
<td class="with-number">81.84 %</td>
|
||||||
<td class="with-bar"><div class="covered"
|
<td class="with-bar"><div class="covered"
|
||||||
style="width:92.47311827956989%;
|
style="width:88.67924528301887%;
|
||||||
float:left;"> 86 </div><div class="partial"
|
float:left;"> 94 </div><div class="partial"
|
||||||
style="width:2.150537634408602%;
|
style="width:2.830188679245283%;
|
||||||
float:left;"> 2 </div><div class="not-covered"
|
float:left;"> 3 </div><div class="not-covered"
|
||||||
style="width:5.376344086021505%;
|
style="width:8.49056603773585%;
|
||||||
float:left;"> 5 </div></td>
|
float:left;"> 9 </div></td>
|
||||||
<td class="with-number">94.62 %</td>
|
<td class="with-number">91.51 %</td>
|
||||||
<td class="with-number">216</td><td class="with-number">23</td><td class="with-number">93</td>
|
<td class="with-number">235</td><td class="with-number">24</td><td class="with-number">106</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">90.74 %</td>
|
<td class="with-number">81.84 %</td>
|
||||||
<td class="with-bar"></td>
|
<td class="with-bar"></td>
|
||||||
<td class="with-number">94.62 %</td>
|
<td class="with-number">91.51 %</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."
|
025 will be sought. Deprecated, prefer `(:resource-path *config*)`."
|
||||||
</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."
|
029 "The default language to seek. Deprecated, prefer `(:default-language *config*)`."
|
||||||
</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,560 +97,617 @@
|
||||||
<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="2 out of 2 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
032 (def accept-language-grammar
|
032 (def ^:dynamic *config*
|
||||||
</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">
|
||||||
033 "Grammar for `Accept-Language` headers"
|
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><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
034 "HEADER := SPECIFIER | SPECIFIERS;
|
035 :resource-path "i18n"})
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
035 SPECIFIERS:= SPECIFIER | SPECIFIER SPEC-SEP SPECIFIERS;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
036 SPEC-SEP := #',\\s*';
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
037 SPECIFIER := LANGUAGE-TAG | LANGUAGE-TAG Q-SEP Q-VALUE;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
038 LANGUAGE-TAG := PRIMARY-TAG | PRIMARY-TAG '-' SUB-TAGS;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
039 PRIMARY-TAG := #'[a-zA-Z]+';
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
040 SUB-TAGS := SUB-TAG | SUB-TAG '-' SUB-TAGS;
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
041 SUB-TAG := #'[a-zA-Z0-9]+';
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
042 Q-SEP := #';\\s*q='
|
|
||||||
</span><br/>
|
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
||||||
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">
|
||||||
044
|
036
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
045 (def parse-accept-language-header
|
037 (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">
|
||||||
046 "Parse an `Accept-Language` header"
|
038 "Grammar for `Accept-Language` headers"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
039 "HEADER := SPECIFIER | SPECIFIERS;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
040 SPECIFIERS:= SPECIFIER | SPECIFIER SPEC-SEP SPECIFIERS;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
041 SPEC-SEP := #',\\s*';
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
042 SPECIFIER := LANGUAGE-TAG | LANGUAGE-TAG Q-SEP Q-VALUE;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
043 LANGUAGE-TAG := PRIMARY-TAG | PRIMARY-TAG '-' SUB-TAGS;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
044 PRIMARY-TAG := #'[a-zA-Z]+';
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
045 SUB-TAGS := SUB-TAG | SUB-TAG '-' SUB-TAGS;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
046 SUB-TAG := #'[a-zA-Z0-9]+';
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
047 Q-SEP := #';\\s*q='
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
048 Q-VALUE := '1' | #'0.[0-9]+';")
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
049
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
050 (def parse-accept-language-header
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
051 "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">
|
||||||
047 (insta/parser accept-language-grammar))
|
052 (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">
|
||||||
048
|
053
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
049 (defn generate-accept-languages
|
054 (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">
|
||||||
050 "From a `parse-tree` generated by the `language-specifier-grammar`, generate
|
055 "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">
|
||||||
051 a list of maps each having a `:language` key, a `:preference` key and a
|
056 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">
|
||||||
052 `:qualifier` key."
|
057 `: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">
|
||||||
053 {:doc/format :markdown}
|
058 {: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">
|
||||||
054 [parse-tree]
|
059 [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">
|
||||||
055 (if
|
060 (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">
|
||||||
056 (nil? parse-tree)
|
061 (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">
|
||||||
057 nil
|
062 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">
|
||||||
058 (case
|
063 (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">
|
||||||
059 (first parse-tree)
|
064 (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">
|
||||||
060 :HEADER (generate-accept-languages (second parse-tree))
|
065 :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">
|
||||||
061 :SPECIFIERS (cons
|
066 :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">
|
||||||
062 (generate-accept-languages (second parse-tree))
|
067 (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">
|
||||||
063 (when (>= (count parse-tree) 3)
|
068 (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">
|
||||||
064 (generate-accept-languages (nth parse-tree 3))))
|
069 (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">
|
||||||
065 :SPEC-SEP nil
|
070 :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">
|
||||||
066 :SPECIFIER (assoc
|
071 :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">
|
||||||
067 (generate-accept-languages (second parse-tree))
|
072 (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">
|
||||||
068 :preference
|
073 :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">
|
||||||
069 (if
|
074 (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">
|
||||||
070 (>= (count parse-tree) 3)
|
075 (>= (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">
|
||||||
071 (generate-accept-languages (nth parse-tree 3))
|
076 (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">
|
||||||
072 1))
|
077 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">
|
||||||
073 :LANGUAGE-TAG (if
|
078 :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">
|
||||||
074 (>= (count parse-tree) 3)
|
079 (>= (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">
|
||||||
075 (assoc
|
080 (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">
|
||||||
076 (generate-accept-languages (second parse-tree))
|
081 (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">
|
||||||
077 :qualifier
|
082 :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">
|
||||||
078 (generate-accept-languages (nth parse-tree 3)))
|
083 (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">
|
||||||
079 (generate-accept-languages (second parse-tree)))
|
084 (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">
|
||||||
080 :PRIMARY-TAG {:language (second parse-tree) :qualifier "*"}
|
085 :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">
|
||||||
081 :SUB-TAGS (if
|
086 :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">
|
||||||
082 (>= (count parse-tree) 3)
|
087 (>= (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">
|
||||||
083 (str
|
088 (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">
|
||||||
084 (generate-accept-languages (second parse-tree))
|
089 (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">
|
||||||
085 "-"
|
090 "-"
|
||||||
</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">
|
||||||
086 (generate-accept-languages (nth parse-tree 3)))
|
091 (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">
|
||||||
087 (generate-accept-languages (second parse-tree)))
|
092 (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">
|
||||||
088 :SUB-TAG (second parse-tree)
|
093 :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">
|
||||||
089 :Q-SEP nil
|
094 :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">
|
||||||
090 :Q-VALUE (read-string (second parse-tree))
|
095 :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">
|
||||||
091 ;; default
|
096 ;; 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">
|
||||||
092 (do
|
097 (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">
|
||||||
093 (timbre/error "Unable to parse header.")
|
098 (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">
|
||||||
094 nil))))
|
099 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="not-tracked" title="0 out of 0 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
101 Returns a list of maps as generated by `generate-accept-languages`, in descending order
|
101 (defn acceptable-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">
|
||||||
102 of preference."
|
102 "Generate an ordered list of acceptable languages, most-preferred first.
|
||||||
|
</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">
|
||||||
103 {:doc/format :markdown}
|
104 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header.
|
||||||
|
</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">
|
||||||
104 [accept-language-header]
|
106 Returns a list of maps as generated by `generate-accept-languages`, in descending order
|
||||||
|
</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">
|
||||||
105 (let [parse-tree (parse-accept-language-header accept-language-header)]
|
110 (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">
|
||||||
106 (if (vector? parse-tree)
|
111 (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">
|
||||||
107 (reverse
|
112 (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">
|
||||||
108 (sort-by
|
113 (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">
|
||||||
109 :preference
|
114 :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">
|
||||||
110 (generate-accept-languages
|
115 (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">
|
||||||
111 parse-tree)))
|
116 parse-tree)))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="21 out of 21 forms covered">
|
<span class="not-covered" title="0 out of 21 forms covered">
|
||||||
112 (timbre/error "Failed to parse Accept-Language header '" accept-language-header "':\n" (str parse-tree)))))
|
117 (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">
|
||||||
113
|
118
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
114
|
119
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
115 (defn slurp-resource
|
120 (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">
|
||||||
116 "Slurp the resource of this name and return its contents as a string; but if it doesn't
|
121 "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">
|
||||||
117 exist log the fact and return nil, rather than throwing an exception."
|
122 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">
|
||||||
118 [name]
|
123 [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">
|
||||||
119 (try
|
124 (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">
|
||||||
120 (slurp (io/resource name))
|
125 (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">
|
||||||
121 (catch Exception _
|
126 (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">
|
||||||
122 (timbre/error (str "Resource at " name " does not exist."))
|
127 (timbre/warn (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">
|
||||||
123 nil)))
|
128 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">
|
||||||
124
|
129
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
125
|
130
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
126 (defn find-language-file-name
|
131 (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">
|
||||||
127 "Find the name of a messages file on this resource path which matches this `language-spec`.
|
132 "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 Returns the name of an appropriate file if any is found, else nil."
|
134 * `language-spec` should be either a map as generated by `generate-accept-languages`, or
|
||||||
</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 {:doc/format :markdown}
|
135 else a string;
|
||||||
</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 [language-spec resource-path]
|
136 * `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">
|
||||||
|
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">
|
||||||
137 (let [file-path (when
|
142 (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">
|
||||||
138 (string? language-spec)
|
143 (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">
|
||||||
139 (join
|
144 (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">
|
||||||
140 java.io.File/separator
|
145 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">
|
||||||
141 [resource-path (str language-spec ".edn")]))
|
146 [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">
|
||||||
142 contents (when file-path (slurp-resource file-path))]
|
147 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">
|
||||||
143 (cond
|
148 (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">
|
||||||
144 contents
|
149 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">
|
||||||
145 file-path
|
150 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">
|
||||||
146 (map? language-spec)
|
151 (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">
|
||||||
147 (or
|
152 (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">
|
||||||
148 (find-language-file-name
|
153 (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">
|
||||||
149 (str (:language language-spec) "-" (:qualifier language-spec))
|
154 (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">
|
||||||
150 resource-path)
|
155 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">
|
||||||
151 (find-language-file-name
|
156 (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">
|
||||||
152 (:language language-spec)
|
157 (: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">
|
||||||
153 resource-path)))))
|
158 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">
|
||||||
154
|
159
|
||||||
</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="not-tracked" title="0 out of 0 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
161 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
161 (defn raw-get-messages
|
||||||
</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 * `resource-path` should be the fully-qualified path name of the directory in which
|
162 "Return the most acceptable messages collection we have given this `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">
|
||||||
163 message files are stored;
|
163 Do not use this function directly, use the memoized variant `get-messages`, as performance
|
||||||
</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 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
164 will be very much better.
|
||||||
</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">
|
||||||
166
|
165
|
||||||
</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 Returns a map of message keys to strings; if no useable file is found, returns nil."
|
166 * `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">
|
||||||
168 {:doc/format :markdown}
|
167 * `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">
|
||||||
169 [^String accept-language-header ^String resource-path ^String default-locale]
|
168 message files are stored;
|
||||||
|
</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">
|
||||||
170 (let [file-path (first
|
175 (let [file-paths (remove
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="2 out of 2 forms covered">
|
|
||||||
171 (remove
|
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
172 nil?
|
176 empty?
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
173 (map
|
177 (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">
|
||||||
174 #(find-language-file-name % resource-path)
|
178 #(find-language-file-name % 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">
|
||||||
175 (acceptable-languages accept-language-header))))]
|
179 (acceptable-languages accept-language-header)))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="20 out of 20 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
176 (timbre/debug (str "Found i18n file at '" file-path "'"))
|
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">
|
||||||
177 (try
|
181 [resource-path
|
||||||
</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><br/>
|
||||||
<span class="covered" title="4 out of 4 forms covered">
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
184 (str default-locale ".edn")]))))
|
182 (str default-locale ".edn")])
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
185 (catch Exception any
|
183 paths (concat file-paths (list default-path))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="19 out of 19 forms covered">
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
186 (timbre/error (str "Failed to load internationalisation because " (.getMessage any)))
|
184 text (first
|
||||||
</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><br/>
|
||||||
<span class="covered" title="3 out of 3 forms covered">
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
199 (memoize raw-get-messages))
|
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 class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
192 (catch Exception any
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 16 forms covered">
|
||||||
|
193 (timbre/error "Failed to load internationalisation because "
|
||||||
|
</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><br/>
|
||||||
<span class="blank" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
200
|
201
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
201 (def get-message
|
202 (def get-messages
|
||||||
</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">
|
||||||
202 "Return the message keyed by this `token` from the most acceptable messages collection
|
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><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
203 we have given this `accept-language-header`.
|
205 * `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">
|
||||||
204
|
206 * `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">
|
||||||
205 * `token` should be a clojure keyword identifying the message to be retrieved;
|
207 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">
|
||||||
206 * `accept-language-header` should be the value of an RFC2616 `Accept-Language` header;
|
208 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
||||||
</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">
|
||||||
207 * `resource-path` should be the fully-qualified path name of the directory in which
|
209 identified.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
210
|
||||||
</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">
|
||||||
208 message files are stored;
|
211 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="covered" title="3 out of 3 forms covered">
|
||||||
209 * `default-locale` should be a locale specifier to use if no acceptable locale can be
|
212 (memoize raw-get-messages))
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
210 identified."
|
213
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="1 out of 1 forms covered">
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
211 (fn ([^Keyword token ^String accept-language-header ^String resource-path ^String default-locale]
|
214 (def get-message
|
||||||
</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><br/>
|
||||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
213 ([^Keyword token ^String accept-language-header]
|
215 "Return the message keyed by this `token` from the most acceptable messages collection
|
||||||
</span><br/>
|
|
||||||
<span class="covered" title="6 out of 6 forms covered">
|
|
||||||
214 (get-message token accept-language-header *resource-path* *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">
|
||||||
215 ([^Keyword token]
|
216 we have given this `accept-language-header`, if passed, or the current default language
|
||||||
</span><br/>
|
</span><br/>
|
||||||
<span class="covered" title="6 out of 6 forms covered">
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
216 (get-message token nil *resource-path* *default-language*))))
|
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.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>
|
<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>
|
|
@ -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.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>
|
<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>
|
||||||
<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.4"]
|
<pre><code>[org.clojars.simon_brooke/internationalisation "1.0.5"]
|
||||||
</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,16 +45,15 @@
|
||||||
|
|
||||||
(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 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>
|
<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>: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>
|
<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 [*resource-path* "language-files"
|
<pre><code class="clojure">(binding [*config* {: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")
|
||||||
|
@ -79,9 +78,19 @@
|
||||||
{: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 may be generated by running</p>
|
<p>Documentation can be found here. It 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.4"
|
(defproject org.clojars.simon_brooke/internationalisation "1.0.5"
|
||||||
: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,13 +22,18 @@
|
||||||
|
|
||||||
(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."
|
will be sought. Deprecated, prefer `(:resource-path *config*)`."
|
||||||
"i18n")
|
"i18n")
|
||||||
|
|
||||||
(def ^:dynamic *default-language*
|
(def ^:dynamic *default-language*
|
||||||
"The default language to seek."
|
"The default language to seek. Deprecated, prefer `(:default-language *config*)`."
|
||||||
(-> (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;
|
||||||
|
@ -119,7 +124,7 @@
|
||||||
(try
|
(try
|
||||||
(slurp (io/resource name))
|
(slurp (io/resource name))
|
||||||
(catch Exception _
|
(catch Exception _
|
||||||
(timbre/error (str "Resource at " name " does not exist."))
|
(timbre/warn (str "Resource at " name " does not exist."))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,23 +172,31 @@
|
||||||
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-path (first
|
(let [file-paths (remove
|
||||||
(remove
|
empty?
|
||||||
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)))
|
||||||
(timbre/debug (str "Found i18n file at '" file-path "'"))
|
default-path (join java.io.File/separator
|
||||||
(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")])
|
||||||
(catch Exception any
|
paths (concat file-paths (list default-path))
|
||||||
(timbre/error (str "Failed to load internationalisation because " (.getMessage any)))
|
text (first
|
||||||
|
(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
|
||||||
|
@ -200,7 +213,8 @@
|
||||||
|
|
||||||
(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`.
|
we have given this `accept-language-header`, if passed, or the current default language
|
||||||
|
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;
|
||||||
|
@ -209,8 +223,13 @@
|
||||||
* `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]
|
||||||
((get-messages accept-language-header resource-path default-locale) token))
|
(let [message (token (get-messages accept-language-header resource-path default-locale))]
|
||||||
|
(or message (name token))))
|
||||||
([^Keyword token ^String accept-language-header]
|
([^Keyword token ^String accept-language-header]
|
||||||
(get-message token accept-language-header *resource-path* *default-language*))
|
(get-message token
|
||||||
|
accept-language-header
|
||||||
|
(or (:resource-path *config*) *resource-path*)
|
||||||
|
(or (:default-language *config*) *default-language*)))
|
||||||
([^Keyword token]
|
([^Keyword token]
|
||||||
(get-message token nil *resource-path* *default-language*))))
|
(get-message token
|
||||||
|
(or (:default-language *config*) *default-language*)))))
|
|
@ -1,7 +1,8 @@
|
||||||
(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 [*default-language*
|
[scot.weft.i18n.core :refer [*config*
|
||||||
|
*default-language*
|
||||||
acceptable-languages
|
acceptable-languages
|
||||||
generate-accept-languages
|
generate-accept-languages
|
||||||
get-message
|
get-message
|
||||||
|
@ -206,7 +207,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
|
||||||
(=
|
(=
|
||||||
|
@ -215,9 +216,25 @@
|
||||||
(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 [*default-language* "en-GB"]
|
(binding [*config* (assoc *config* :default-language "fr-FR")]
|
||||||
(is (= "This is not a pipe" (get-message :pipe)))
|
(is (= "Ceci n'est pas une pipe." (get-message :pipe)))
|
||||||
(is
|
(is
|
||||||
(=
|
(=
|
||||||
"Ceci n'est pas une pipe." (get-message :pipe "en-GB;q=0.9, fr-FR")))
|
"This is not a pipe." (get-message :pipe "en-GB, fr-FR;q=0.9")))
|
||||||
(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