padde / polyglot

Localization library for Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Polyglot

Build Status Hex Version

Polyglot is a localization library for Elixir that provides reusable formatting rules and translations for a large number of languages.

The data is fetched from the Unicode Common Locale Data Repository (CLDR) and prepared for easy usage from within Elixir.

Installation

Add :polyglot to your list of dependencies in mix.exs:

def deps do
  [{:polyglot, "~> 0.0.1"}]
end

Usage

Use Polyglot.Data.get/2 to retrieve translations. A comprehensive list of all available translations is available in the documentation for the Polyglot.Data module.

iex> Polyglot.Data.get(:weekdays, :fr)
{:ok, ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]}

iex> Polyglot.Data.get(:weekdays_abbr, :en)
{:ok, ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}

Configuration

By default, translations for all available locales will be available. You can provide a list of enabled locales to speed up compilation time via Mix configuration, for example:

config :polyglot, enabled_locales: [:de, :en, :es, :fr, :it]

For a list of all available locales, use Polyglot.Data.available_locales/0. For a list of enabled locales, use Polyglot.Data.enabled_locales/0.

Contributing

All contributions are welcome. Please feel free to open a pull request on GitHub.

License

Polyglot is released under the MIT license. See the LICENSE file.

The Unicode CLDR data is released under the Unicode Terms of Use, a copy of which is included as UNICODE_LICENSE.

About

Localization library for Elixir

License:MIT License


Languages

Language:Elixir 100.0%