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

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews