{"id":28430952,"url":"https://github.com/elixir-cldr/cldr_locale_display","last_synced_at":"2025-08-31T05:38:22.699Z","repository":{"id":43357458,"uuid":"381335061","full_name":"elixir-cldr/cldr_locale_display","owner":"elixir-cldr","description":"Display name composition for CLDR language tags","archived":false,"fork":false,"pushed_at":"2025-03-18T05:10:55.000Z","size":225,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-25T17:17:47.314Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elixir-cldr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-29T11:06:07.000Z","updated_at":"2025-03-18T05:09:15.000Z","dependencies_parsed_at":"2024-01-02T12:42:47.460Z","dependency_job_id":null,"html_url":"https://github.com/elixir-cldr/cldr_locale_display","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/elixir-cldr/cldr_locale_display","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-cldr%2Fcldr_locale_display","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-cldr%2Fcldr_locale_display/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-cldr%2Fcldr_locale_display/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-cldr%2Fcldr_locale_display/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-cldr","download_url":"https://codeload.github.com/elixir-cldr/cldr_locale_display/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-cldr%2Fcldr_locale_display/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272942399,"owners_count":25019329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-05T14:30:37.281Z","updated_at":"2025-08-31T05:38:22.692Z","avatar_url":"https://github.com/elixir-cldr.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cldr Locale Display\n[![Hex.pm](https://img.shields.io/hexpm/v/ex_cldr_locale_display.svg)](https://hex.pm/packages/ex_cldr_locale_display)\n[![Hex.pm](https://img.shields.io/hexpm/dw/ex_cldr_locale_display.svg?)](https://hex.pm/packages/ex_cldr_locale_display)\n[![Hex.pm](https://img.shields.io/hexpm/dt/ex_cldr_locale_display.svg?)](https://hex.pm/packages/ex_cldr_locale_display)\n[![Hex.pm](https://img.shields.io/hexpm/l/ex_cldr_locale_display.svg)](https://hex.pm/packages/ex_cldr_locale_display)\n\nPresents language tags in a presentation format suitable for UI applications.\nIt implements the [CLDR locale display name algorithm](https://unicode-org.github.io/cldr/ldml/tr35-general.html#locale_display_name_algorithm).\n\n## Installation\n\nThe package can be installed by adding `ex_cldr_locale_display` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:ex_cldr_locale_display, \"~\u003e 1.1\"}\n  ]\nend\n```\n\nDocumentation can be found at [https://hexdocs.pm/ex_cldr_locale_display](https://hexdocs.pm/ex_cldr_locale_display).\n\n## Configuration\n\nIn keeping with all `ex_cldr`-based libraries, a backend module is required which hosts the display data used to produce locale display names. A simple example is given here. For full information on configuring a backend module, see the [configuration section](https://hexdocs.pm/ex_cldr/readme.html#configuration) for [ex_cldr](https://hex.pm/packages/ex_cldr).\n\n```elixir\ndefmodule MyApp.Cldr do\n  use Cldr,\n    locales: [\"en\", \"de\", \"th\", \"fr\", \"fr-CH\", \"zh\", \"ar\"],\n    default_locale: \"en\",\n    providers: [Cldr.Territory, Cldr.LocaleDisplay, Cldr.Currency]\nend\n```\n## Examples\n\nThe follow examples require that a `:default_backend` be set in `config.exs` for the `:ex_cldr` configuration key. See the [configuration section](https://hexdocs.pm/ex_cldr/readme.html#configuration) for [ex_cldr](https://hex.pm/packages/ex_cldr) for more information.\n\n```elixir\niex\u003e Cldr.LocaleDisplay.display_name \"en\"\n{:ok, \"English\"}\n\niex\u003e Cldr.LocaleDisplay.display_name \"en-US\"\n{:ok, \"American English\"}\n\niex\u003e Cldr.LocaleDisplay.display_name \"en-US\", compound_locale: false\n{:ok, \"English (United States)\"}\n\niex\u003e Cldr.LocaleDisplay.display_name \"en-US-u-ca-gregory-cu-aud\"\n{:ok, \"American English (Gregorian Calendar, Currency: A$)\"}\n\niex\u003e Cldr.LocaleDisplay.display_name \"en-US-u-ca-gregory-cu-aud\", locale: \"fr\"\n{:ok, \"anglais américain (calendrier grégorien, devise : A$)\"}\n\niex\u003e Cldr.LocaleDisplay.display_name \"nl-BE\"\n{:ok, \"Flemish\"}\n\niex\u003e Cldr.LocaleDisplay.display_name \"nl-BE\", compound_locale: false\n{:ok, \"Dutch (Belgium)\"}\n```\n\n### Rendering a list of locales in their own languages\n\nWhen presenting a list of locales to a user for selection it may be appropriate to present those display name in the language of the locale. The package [ex_cldr_html](https://hex.pm/packages/ex_cldr_html) includes a helper function for this but a simple approach is also possible.\n\nThe following snippet renders the list of known locales as display names in each locales own language. It uses a backend module configuration noted above.\n\n```elixir\niex\u003e MyApp.Cldr.known_locale_names()\n.... |\u003e Enum.map(\u0026{\u00261, MyApp.Cldr.LocaleDisplay.display_name!(\u00261, locale: \u00261, prefer: :menu)})\n.... |\u003e Enum.sort\n[\n  {\"ar\", \"العربية\"},\n  {\"de\", \"Deutsch\"},\n  {\"en\", \"English\"},\n  {\"fr\", \"français\"},\n  {\"fr-CH\", \"français suisse\"},\n  {\"th\", \"ไทย\"},\n  {\"zh-Hans\", \"简体中文\"},\n  {\"zh-Hant\", \"繁體中文\"}\n]\n\n# In some cases it is preferred to not use compound\n# locale names. Note the different rendering for the\n# locale fr-CH\niex\u003e MyApp.Cldr.known_locale_names\n.... |\u003e Enum.map(\u0026{\u00261, MyApp.Cldr.LocaleDisplay.display_name!(\u00261, locale: \u00261, compound_locale: false, prefer: :menu)})\n.... |\u003e Enum.sort\n[\n  {\"ar\", \"العربية\"},\n  {\"de\", \"Deutsch\"},\n  {\"en\", \"English\"},\n  {\"fr\", \"français\"},\n  {\"fr-CH\", \"français (Suisse)\"},\n  {\"th\", \"ไทย\"},\n  {\"zh-Hans\", \"简体中文（简体）\"},\n  {\"zh-Hant\", \"繁體中文（繁體）\"}\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-cldr%2Fcldr_locale_display","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-cldr%2Fcldr_locale_display","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-cldr%2Fcldr_locale_display/lists"}