Liking cljdoc? Tell your friends :D

trptr.java-wrapper.locale

Clojure wrapper for java.util.Locale.

The main fn: locale.

Note: wherever a Java method requires a Locale object, not only such an object, but also a "locale specification" is accepted. In such cases the Java method (called by the Clojure wrapper) will get the Locale object "specified" by the "specification". This means, that (unless we pass a Locale object already to the Clojure wrapper), the needed Locale object is created "on the fly", "behind the scenes", inside the Clojure wrapper.

Below are the possibilities for such "locale specifications" and their interpretations.

  • nil
    In this case the Locale object, "specified" by this "specification" is the one returned by Java's Locale.getDefault().

  • a Java Locale object
    In this case the resulting Locale object is the same as the "specification".

  • a map with keys corresponding to the Locale.Builder class' setXXX instance methods, i.e. :language, :region, :script, :variant, etc.
    The resulting Locale object is the one returned by a corresponding build call. See examples at build.

  • a keyword or string
    In this case the "specification" is splitted at "-" and "_" characters;
    the resulting Locale object is the one returned by make-locale applied on the result of the splitting.

For more info see locale.

Clojure wrapper for java.util.Locale.

The main fn: [[locale]].

Note: wherever a Java method requires a Locale object, not only such an object,
but also a "locale specification" is accepted.
In such cases the Java method (called by the Clojure wrapper) will get
the Locale object "specified" by the "specification". This means, that
(unless we pass a Locale object already to the Clojure wrapper), the needed Locale object
is created "on the fly", "behind the scenes", inside the Clojure wrapper.

Below are the possibilities for such "**locale specifications**" and their interpretations.

* **`nil`**  
In this case the Locale object, "specified" by this "specification"
is the one returned by Java's `Locale.getDefault()`.

* a **Java Locale object**  
In this case the resulting Locale object is the same as the "specification".

* a **map** with keys corresponding to the Locale.Builder class' setXXX instance methods,
i.e. `:language`, `:region`, `:script`, `:variant`, etc.  
The resulting Locale object is the one
returned by a corresponding [[build]] call. See examples at [[build]].

* a **keyword** or **string**  
In this case the "specification" is splitted at "-" and "_" characters;  
the resulting Locale object is the one returned by
[[make-locale]] applied on the result of the splitting.

For more info see [[locale]].
raw docstring

available-localesclj

Wrapper of the Java method 'getAvailableLocales', as a set.
Can be used to check e.g. if a freshly made Locale object is 'valid' on the system:
(available-locales (locale :-an)) is usually nil, while there is a good chance that e.g. (available-locales (locale :en)) is truethy...

Wrapper of the Java method 'getAvailableLocales', as a set.  
Can be used to check e.g. if a freshly made Locale object is 'valid' on the system:  
`(available-locales (locale :-an))` is usually `nil`, while there is a good chance that
e.g. `(available-locales (locale :en))` is truethy...
sourceraw docstring

buildclj

(build {:keys [language language-tag locale region script variant]})

Wrapper of Java's Locale.Builder/build.

Notes:

  • sets locale first (if any), then the others. So the properties of locale might be overwritten in the result.
  • language and region can be strings or keywords and are case insensitive.
  • use empty strings for the removal of settings.

Examples:

(get-display-country (build {:region "029"})) ;; → Caribbean
(get-display-script {:script "Arab"}) ;; → Arabic
(build {:language-tag "de-POSIX-x-URP-lvariant-Abc-Def"})
;; → #object[java.util.Locale 0x68230234 "de__POSIX_Abc_Def_#x-urp"]

See also to-language-tag!

Wrapper of Java's Locale.Builder/build.

Notes:  
* sets `locale` first (if any), then the others.
  So the properties of `locale` might be overwritten in the result.  
* `language` and `region` can be strings or keywords and are case insensitive.  
* use empty strings for the removal of settings.

Examples:
```clojure
(get-display-country (build {:region "029"})) ;; → Caribbean
```
```clojure
(get-display-script {:script "Arab"}) ;; → Arabic
```
```clojure
(build {:language-tag "de-POSIX-x-URP-lvariant-Abc-Def"})
;; → #object[java.util.Locale 0x68230234 "de__POSIX_Abc_Def_#x-urp"]
```

See also [[to-language-tag]]!
sourceraw docstring

categoriesclj

Java Locale.Category constants in a map with keys:locale.category/display and :locale.category/format.

Java Locale.Category constants in a map with keys`:locale.category/display` and `:locale.category/format`.
sourceraw docstring

country-codeclj

Turns its argument into a "normalized" country code string.

Turns its argument into a "normalized" country code string.
sourceraw docstring

for-language-tagclj

(for-language-tag language-tag)

Direct wrapper of the Java method. See also to-language-tag!
Example: (for-language-tag "fr-FR")#object[java.util.Locale 0x163fd507 "fr_FR"].

Direct wrapper of the Java method. See also [[to-language-tag]]!  
Example: `(for-language-tag "fr-FR")` → `#object[java.util.Locale 0x163fd507 "fr_FR"]`.
sourceraw docstring

get-countryclj

(get-country loc__1764__auto__)

Wrapper of the Java method getCountry, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getCountry`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-defaultclj

(get-default)
(get-default locale-category)

Direct wrapper of the Java method.
locale-category is a value from the map categories.

Direct wrapper of the Java method.  
`locale-category` is a value from the map [[categories]].
sourceraw docstring

get-display-countryclj

(get-display-country loc__1780__auto__)
(get-display-country loc__1780__auto__ in-locale__1781__auto__)

Wrapper of the Java method getDisplayCountry, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getDisplayCountry`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-display-languageclj

(get-display-language loc__1780__auto__)
(get-display-language loc__1780__auto__ in-locale__1781__auto__)

Wrapper of the Java method getDisplayLanguage, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getDisplayLanguage`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-display-nameclj

(get-display-name loc__1780__auto__)
(get-display-name loc__1780__auto__ in-locale__1781__auto__)

Wrapper of the Java method getDisplayName, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getDisplayName`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-display-scriptclj

(get-display-script loc__1780__auto__)
(get-display-script loc__1780__auto__ in-locale__1781__auto__)

Wrapper of the Java method getDisplayScript, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getDisplayScript`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-display-variantclj

(get-display-variant loc__1780__auto__)
(get-display-variant loc__1780__auto__ in-locale__1781__auto__)

Wrapper of the Java method getDisplayVariant, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getDisplayVariant`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-iso-3-countryclj

(get-iso-3-country loc)

Wrapper of the Java method getIso3Country, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".
Note: if the argument is a string or a keyword, then the country comes from the second subtag. So use e.g. :-an or "-an" instead of :an or "an".

Wrapper of the Java method `getIso3Country`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".  
Note: if the argument is a string or a keyword, then 
  the country comes from the second subtag.
  So use e.g. `:-an` or "-an" instead of `:an` or "an".
sourceraw docstring

get-iso-3-languageclj

(get-iso-3-language loc)

Wrapper of the Java method getIso3Language, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getIso3Language`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-iso-countriesclj

Direct wrapper of the Java method. Consider using iso-countries instead.

Direct wrapper of the Java method. Consider using [[iso-countries]] instead.
sourceraw docstring

get-iso-languagesclj

Direct wrapper of the Java method. Consider using iso-languages instead.

Direct wrapper of the Java method. Consider using [[iso-languages]] instead.
sourceraw docstring

get-languageclj

(get-language loc__1764__auto__)

Wrapper of the Java method getLanguage, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getLanguage`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-scriptclj

(get-script loc__1764__auto__)

Wrapper of the Java method getScript, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getScript`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

get-variantclj

(get-variant loc__1764__auto__)

Wrapper of the Java method getVariant, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `getVariant`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

has-extensionsclj

(has-extensions loc__1764__auto__)

Wrapper of the Java method hasExtensions, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `hasExtensions`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

iso-countriesclj

All Java ISO country codes as Clojure keywords, in a set.

All Java ISO country codes as Clojure keywords, in a set.
sourceraw docstring

iso-country-kwclj

Turns its argument into an ISO country code keyword OR nil.

Turns its argument into an ISO country code keyword OR `nil`.
sourceraw docstring

iso-language-kwclj

Turns its argument into an ISO language code keyword OR nil.

Turns its argument into an ISO language code keyword OR `nil`.
sourceraw docstring

iso-languagesclj

All Java ISO language codes as Clojure keywords, in a set.

All Java ISO language codes as Clojure keywords, in a set. 
sourceraw docstring

language-codeclj

Turns its argument into a "normalized" language code string.

Turns its argument into a "normalized" language code string.
sourceraw docstring

localeclj

(locale)
(locale spec)
(locale lang & others)

The main Locale creator API: returns a Java Locale object if called:

  • without arguments;
  • with 1 "locale specification" (see the docstring of this ns, above);
  • a series of proper string or keyword subtags.

Returns the defualt locale in case of no arguments or if its single argument is nil.

Returns its single argument untouched if it is already a Locale object.

If it gets 2 or more arguments, they are passed untouched to make-locale.

If it gets a single map, it is passed untouched to build.

Otherwise it turns the got string or keyword (you choose!) into a series of strings (by split-locale) and then passes the result to make-locale.

Valid spec examples: "fr-ar", "EN_CA-variaNt", :ar--vari2, :-ng, :ru_CN, {:variant "varIAnt"}.

The main Locale creator API: returns a Java Locale object if called:  
* without arguments;  
* with 1 "locale specification" (see the docstring of this ns, above);  
* a series of proper string or keyword subtags.

Returns the defualt locale in case of no arguments or if its single argument is nil.

Returns its single argument untouched if it is already a Locale object.

If it gets 2 or more arguments, they are passed untouched to [[make-locale]].

If it gets a single map, it is passed untouched to [[build]].

Otherwise it turns the got string or keyword (you choose!) into a
series of strings (by [[split-locale]]) and then passes the result to [[make-locale]].

Valid `spec` examples:
`"fr-ar"`, `"EN_CA-variaNt"`, `:ar--vari2`, `:-ng`, `:ru_CN`, `{:variant "varIAnt"}`.
sourceraw docstring

low-kwclj

Turns its argument into a keyword of lowercase letters.

Turns its argument into a keyword of lowercase letters.
sourceraw docstring

make-localeclj

(make-locale lang)
(make-locale lang country)
(make-locale lang country variant)

Wrapper of java.util.Locale's constructor: creates a Java Locale object from:

  • a language code OR keyword ("en" or :en) and
  • an optional country code OR keyword ("DE" or :de) and
  • an optional vendor-specific variant code.
    Case insensitive.
Wrapper of java.util.Locale's constructor: creates a Java Locale object from:  
* a language code OR keyword ("en" or :en) and  
* an optional country code OR keyword ("DE" or :de) and  
* an optional vendor-specific variant code.  
Case insensitive.
sourceraw docstring

predef-localesclj

The constants from the Java class' static fields in a map with keys :locale/english, :locale/uk, etc. Not all Java constants are wrapped yet.

The constants from the Java class' static fields in a map
with keys `:locale/english`, `:locale/uk`, etc.
Not all Java constants are wrapped yet.
sourceraw docstring

set-defaultclj

(set-default new-locale)
(set-default locale-category new-locale)

Wrapper of the Java method setDefault, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `setDefault`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

split-localeclj

Accepts a string or a keyword and returns a vector of strings created from the argument's parts.
The argument's parts must be separated by either a dash ("-") or an underscore ("_").
Keywords' namespaces are ignored.

Accepts a string or a keyword and returns a vector of strings created from the argument's parts.  
The argument's parts must be separated by either a dash ("-") or an underscore ("_").  
Keywords' namespaces are ignored.
sourceraw docstring

strip-extensionsclj

(strip-extensions loc__1764__auto__)

Wrapper of the Java method stripExtensions, but accepts "locale specifications" as well (not only Locale objects). See the docstring of this ns (above), for the description of "locale specifications".

Wrapper of the Java method `stripExtensions`, but accepts "locale specifications" as well  (not only Locale objects).  See the docstring of this `ns` (above), for the description of "locale specifications".
sourceraw docstring

to-language-tagclj

(to-language-tag loc)

Wrapper of the Java method, but accepts "locale specifications" as well.

Can be used to 'serialize' a Locale object as a string, that can later be used to recreate the object: (build {:language-tag (to-language-tag <some-locale>)}) should result <some-locale>.

See also Java doc for Compatibility of Locale: "toLanguageTag cannot represent the state of locales whose language, country, or variant do not conform to BCP 47.

[...] it is recommended that clients migrate away from constructing non-conforming locales and use the forLanguageTag and Locale.Builder APIs instead.

Clients desiring a string representation of the complete locale can then always rely on toLanguageTag for this purpose."

Wrapper of the Java method, but accepts "locale specifications" as well.  

Can be used to 'serialize' a Locale object as a string, that can later be used to recreate the object:
`(build {:language-tag (to-language-tag <some-locale>)})` should result `<some-locale>`.

See also Java doc for Compatibility of Locale: "toLanguageTag cannot represent the state of locales
whose language, country, or variant do not conform to BCP 47.

[...] it is recommended that clients migrate away from constructing non-conforming locales
and use the forLanguageTag and Locale.Builder APIs instead.

Clients desiring a string representation of the complete locale can then always rely on toLanguageTag for this purpose."
sourceraw docstring

unicode-locale-extensionclj

The Java constant.

The Java constant.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close