benkeil

benkeil

As a followup from How does it work? · Issue #152 · elixir-cldr/cldr · GitHub

The repo has files like de_DE, de_IT, de_AT. Why these are not valid during configuration? If the goal of all that sub packages is, to save space, then it should also be possible to just download e.g. de_AT.

defmodule WidgetWeb.Cldr do
  use Cldr,
      default_locale: "en-GB",
      locales: ["en-GB", "de-DE", "th"],
      add_fallback_locales: false,
      otp_app: :widget_web,
      providers: [Cldr.Number, Cldr.Message],
      precompile_number_formats: ["¤¤#,##0.##"],
      precompile_transliterations: [{:latn, :arab}, {:thai, :latn}],
      generate_docs: true,
      force_locale_download: false
end
== Compilation error in file lib/widget_web/services/cldr.ex ==
** (Cldr.UnknownLocaleError) Failed to install the locale named "de_DE". The locale name is not known.
    (ex_cldr 2.23.0) lib/cldr/install.ex:84: Cldr.Install.do_install_locale_name/3
    (elixir 1.12.2) lib/enum.ex:930: Enum."-each/2-lists^foreach/1-0-"/2
    (ex_cldr 2.23.0) lib/cldr/install.ex:28: Cldr.Install.install_known_locale_names/1
    (ex_cldr 2.23.0) lib/cldr.ex:81: Cldr.install_locales/1
    (ex_cldr 2.23.0) expanding macro: Cldr.Backend.Compiler.__before_compile__/1
    lib/widget_web/services/cldr.ex:1: WidgetWeb.Cldr (module)
    (elixir 1.12.2) lib/kernel/parallel_compiler.ex:319: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

Showing Posts 1 to 7

kip

kip

ex_cldr Core Team

As the message says:

== Compilation error in file lib/widget_web/services/cldr.ex ==
** (Cldr.UnknownLocaleError) Failed to install the locale named “de_DE”. The locale name is not known.
(ex_cldr 2.23.0) lib/cldr/install.ex:84: Cldr.Install.do_install_locale_name/3

There is no CLDR locale “de-DE” so an exception is raised during compilation. Replace “de-DE” with “de” and you should be good to go. In fact a backend configuration can be reduced to the following given the various defaults:

defmodule WidgetWeb.Cldr do
  use Cldr,
      default_locale: "en-GB",
      locales: ["en-GB", "de-DE", "th"],
      otp_app: :widget_web,
      providers: [Cldr.Number, Cldr.Message],

      # These two only required if you need them
      # In most cases you probably don't
      precompile_number_formats: ["¤¤#,##0.##"],
      precompile_transliterations: [{:latn, :arab}, {:thai, :latn}],
end
benkeil

benkeil OP

I still don’t get it, in this repo: cldr/common/main at main · unicode-org/cldr · GitHub is a file de_DE, which is a CLDR locale, or not?

kip

kip

ex_cldr Core Team

The locales available to ex_cldr are those in the available_locales.json file in the ex_cldr repository. Or you can see the local files in json format in the priv/cldr/locales directory.

You can also see the available locales as follows:

iex> Cldr.Config.all_locale_names()
["af", "af-NA", "agq", "ak", "am", "ar", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ",
 "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW",
 "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA",
 "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "as", "asa",
 "ast", "az", "az-Cyrl", "az-Latn", "bas", "be", "be-tarask", "bem", "bez",
 "bg", "bm", "bn", "bn-IN", "bo", "bo-IN", ...]

If you look inside the CLDR repo in common/main/de_DE.xml file you’ll see it actually has no locale content and therefore not an available locale. As noted in the issue you raised, the locale de is already “German as spoke in Germany” and therefore de-DE isn’t populated. The same is true for en-US - in CLDR its an empty locale file because en is already “English as spoken in the US”.

benkeil

benkeil OP

Jesus, now I got you. But I still belief it would be nice to allow de-DE. I guess a lot of people fall about this and the locale for Germany is will de-DE. It clearer.
Like cldr/common/main/de_DE.xml at main · unicode-org/cldr · GitHub is an alias to cldr/common/main/de.xml at main · unicode-org/cldr · GitHub it should be allowed in the code to use it.

kip

kip

ex_cldr Core Team

A user can still specify de-DE if they want, ex_cldr will resolve to the nearest available locale which will be de if it is configured.

benkeil

benkeil OP

The thing is nobody understand that you should use de for de-DE but de-AT for Austrian.

kip

kip

ex_cldr Core Team

You can also use de-DE from a user experience point of view. It is only configuration of a backend that has this consideration.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews