Skip to content

elixir-cldr/cldr_languages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cldr Languages

Hex.pm Hex.pm Hex.pm

ex_cldr_languages is an addon library application for ex_cldr that provides localization and listing of languages.

Installation

Add :ex_cldr_languages to your deps:

def deps do
  [
    {:ex_cldr_languages, "~> 0.3.0"}
  ]
end

Then register Cldr.Language as a provider in your Cldr backend module (see the ex_cldr setup instructions for the backend itself):

defmodule MyApp.Cldr do
  use Cldr,
    locales: ["en", "de", "fr"],
    default_locale: "en",
    providers: [Cldr.Language]
end

The library's functionality is then available on MyApp.Cldr.Language:

iex> MyApp.Cldr.Language.to_string "en-GB"
{:ok, "British English"}

iex> MyApp.Cldr.Language.to_string "en-GB", style: :short
{:ok, "UK English"}

iex> MyApp.Cldr.Language.to_string "en", locale: "de"
{:ok, "Englisch"}

The MyApp.Cldr module name above is the conventional placeholder used throughout the ex_cldr ecosystem. Substitute your own backend module name if you've chosen a different one.

Migration from v0.1.1 to v0.2.0

With the switch to ex_cldr v2 any functionality is now called via MyApp.Cldr.Language (the language provider compiled into your Cldr backend) instead of the top-level Cldr.Language module. This breaking change was also used to remove all_languages/0 in favor of available_languages/0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages