Cldr.List.to_string

You're seeing just the function to_string, go back to Cldr.List module for more information.
Link to this function

to_string(list, backend \\ default_backend(), options \\ [])

View Source

Specs

to_string([term(), ...], Cldr.backend() | Keyword.t(), Keyword.t()) ::
  {:ok, String.t()} | {:error, {atom(), binary()}}

Formats a list into a string according to the list pattern rules for a locale.

Arguments

  • list is any list of of terms that can be passed through Kernel.to_string/1

  • options is a keyword list

Options

  • :locale is any configured locale. See Cldr.known_locales(). The default is locale: Cldr.get_locale/1

  • :format is one of those returned by Cldr.List.known_list_formats/0. The default is format: :standard

Examples

iex> Cldr.List.to_string(["a", "b", "c"], MyApp.Cldr, locale: "en")
{:ok, "a, b, and c"}

iex> Cldr.List.to_string(["a", "b", "c"], MyApp.Cldr, locale: "en", format: :unit_narrow)
{:ok, "a b c"}

iex> Cldr.List.to_string(["a", "b", "c"], MyApp.Cldr, locale: "fr")
{:ok, "a, b et c"}

iex> Cldr.List.to_string([1,2,3,4,5,6], MyApp.Cldr)
{:ok, "1, 2, 3, 4, 5, and 6"}

iex> Cldr.List.to_string(["a"], MyApp.Cldr)
{:ok, "a"}

iex> Cldr.List.to_string([1,2], MyApp.Cldr)
{:ok, "1 and 2"}