Skip to content

fewlinesco/locale_names

Repository files navigation

Locale Names

CircleCI

⚠️ This library is no more maintained as we don't use it anymore. ⚠️

This library provides functions for knowing:

  • How is a locale spelled in its own language (en-US is "American English", fr-CA is "Français canadien")
  • What is the reading direction of the language of a locale (left to right or right to left)
  • If a given string matches a locale

This project supports all modern locales from the CLDR Project except the root locale as it does not make sense in a context where we need locales.

Installation

If available in Hex, the package can be installed by adding locale_names to your list of dependencies in mix.exs:

def deps do
  [
    {:locale_names, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/locale_names.

Usage

locale?(locale_code) will return a boolean representing if the string matches a locale or not locale(locale_code) will return a tuple that looks like this:

{:ok,
  %Locale{
    direction: :left_to_right,
    english_name: "Canadian French",
    locale_code: "fr-CA",
    name: "Français canadien"
  }
}

or an error {:error, :locale_not_found}

Tests

mix test

If you're launching the tests for the first time, continue reading:

The tests will do a benchmark and fail if the results are significantly slower than the baseline. To update the benchmark base file against which tests are compared:

mix benchmark --json --update-json

About

Get locale names in their native form

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published