taoensso.tower
Simple internationalization (i18n) and localization (L10n) library for
Clojure/Script. Wraps standard Java/Script facilities when possible.
country-name
(country-name code display-loc)
default-tfmt-str
(default-tfmt-str loc fmt & args)
Implementation detail. Based on `encore/format`.
dict-compile
Implementation detail.
Compiles text translations stored in simple development-friendly Clojure map
into form required by localized text translator:
{:en {:example {:foo <tr>}}} => {:example/foo {:en <decorated-tr>}}
dict-compile*
macro
(dict-compile* dict & [opts])
dict-load*
macro
(dict-load* dict)
dictionary->xliff
(dictionary->xliff m)
example-tconfig
Example/test config as passed to `make-t`, Ring middleware, etc.
:dictionary should be a map, or named resource containing a map of form
{:locale {:ns1 ... {:nsN {:key<decorator> text ...} ...} ...} ...}}.
Named resource will be watched for changes when `:dev-mode?` is true.
fmt
(fmt loc x & [style])
Formats Date/Number as a string.
`style` is <:#{date time dt}-#{default short medium long full}>,
e.g. :date-full, :time-short, etc. (default :date-default).
fmt-msg
(fmt-msg loc pattern & args)
Creates a localized MessageFormat and uses it to format given pattern string,
substituting arguments as per MessageFormat spec.
fmt-str
(fmt-str loc fmt & args)
Like clojure.core/format but takes a locale, doesn't throw on nil pattern.
get-countries
Experimental. Useful format for [sorted] lists, stitching into maps.
get-langs
Experimental. Useful format for [sorted] lists, stitching into maps.
get-timezones
Experimental. Useful format for [sorted] lists, stitching into maps.
jvm-locale
Returns valid Locale matching given name string/keyword, or throws an
exception if none could be found. `loc` should be of form :en, :en-US,
:en-US-variant, or :jvm-default.
kw-locale
"en_gb-var1" -> :en-gb-var1, etc.
lang-name
(lang-name code & [?display-loc])
lcomparator
(lcomparator loc & [style])
Returns localized comparator.
load-dictionary-from-map-resource!
(load-dictionary-from-map-resource!)
(load-dictionary-from-map-resource! resource-name & [merge?])
lsort
(lsort loc coll & [style])
Localized sort. `style` e/o #{:asc :desc} (default :asc).
merge-config!
(merge-config! & maps)
normalize
(normalize s & [form])
Transforms Unicode string into W3C-recommended standard de/composition form
allowing easier searching and sorting of strings. Normalization is considered
good hygiene when communicating with a DB or other software.
parse
(parse loc s & [style])
Parses date/number string as a Date/Number. See `fmt` for possible `style`s
(default :number).
parse-currency
(parse-currency s)
parse-date
(parse-date s)
(parse-date style s)
parse-dt
(parse-dt s)
(parse-dt dstyle tstyle s)
parse-integer
(parse-integer s)
parse-Locale
(parse-Locale loc)
DEPRECATED: Use `locale` instead.
parse-number
(parse-number s)
parse-percent
(parse-percent s)
parse-time
(parse-time s)
(parse-time style s)
scoped
Merges scope keywords: (scope :a.b :c/d :e) => :a.b.c.d/e
set-config!
(set-config! ks val)
sorted-localized-countries
sorted-localized-languages
style
(style)
(style style)
t
(t loc tconfig k-or-ks & fmt-args)
DEPRECATED. Use `make-t` instead.
timezone
(timezone)
(timezone tz-id)
translate
(translate loc tconfig scope k-or-ks & fmt-args)
DEPRECATED. Use `make-t` instead.
try-jvm-locale
(try-jvm-locale loc & [lang-only?])
Like `jvm-locale` but returns nil if no valid matching Locale could be found.
with-locale
macro
(with-locale loc & body)
with-scope
macro
(with-scope translation-scope & body)
with-tscope
macro
(with-tscope translation-scope & body)
Executes body with given translation scope binding.
xliff->dictionary
(xliff->dictionary s)