Cldr v0.0.8 Cldr.Install

Support for installing locales on demand.

When installed as a package on from hex, Cldr has only the default locale, “en”, installed and configured.

When other locales are added to the configuration Cldr will attempt to download the locale from github during compilation.

If Cldr is installed from github directly then all locales are already installed.

Summary

Functions

Builds the base url to retrieve a locale file from github

Returns the directory where Cldr stores the core CLDR data

Returns the directory where Cldr stores locales that can be used in a client app

Returns the directory where the client app stores Cldr data

Returns the directory into which locale files are stored for a client application

Returns the path of the consolidated locale file stored in the Cldr package (not the client application)

Install all available locales

Install all the configured locales

Download the requested locale from github into the client app data directory

Returns a boolean indicating if the requested locale is installed

Functions

base_url()

Builds the base url to retrieve a locale file from github.

The url is build using the version number of the Cldr application. If the version is a -dev version then the locale file is downloaded from the master branch.

cldr_data_dir()

Returns the directory where Cldr stores the core CLDR data

cldr_locale_dir()

Returns the directory where Cldr stores locales that can be used in a client app.

Current strategy is to only package the “en” locale in Cldr itself and that any other locales are downloaded when configured and the client app is compiled with Cldr as a dep.

client_data_dir()

Returns the directory where the client app stores Cldr data

client_locale_dir()

Returns the directory into which locale files are stored for a client application.

The directory is relative to the configured data directory for a client application. That is typically ./priv/cldr so that locales typically get stored in ./priv/cldr/locales.

client_locale_file(locale)
consolidated_locale_file(locale)

Returns the path of the consolidated locale file stored in the Cldr package (not the client application).

Since these consolidated files go in the github repo we consoldiate them into the Cldr data directory which is Cldr.Config.cldr_home() <> /priv/cldr/locales.

do_install_locale(locale, bool)
install_all_locales()

Install all available locales.

install_known_locales()

Install all the configured locales.

install_locale(locale, options \\ [])

Download the requested locale from github into the client app data directory.

The data directory is typically ./priv/cldr/locales.

This function is intended to be invoked during application compilation when a valid locale is configured but is not yet installed in the application.

An http request to the master github repository for Cldr is made to download the correct version of the locale file which is then written to the configured data directory.

locale_installed?(locale)

Returns a boolean indicating if the requested locale is installed.

No checking of the validity of the locale itself is performed. The check is based upon whether there is a locale file installed in the client application or in Cldr itself.