<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="212831" data-post-id="212831">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/120/1440_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>ex_cldr Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes, definitely looks like a bug.  Would you mind opening an issue on <a href="https://github.com/elixir-cldr/cldr_dates_times" rel="nofollow">ex_cldr_dates_times</a>?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="212831" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/62">Post #61</a>
	                </div>
	            </div>
              <div id="likers-container-212831" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="212831"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #61"></div>
  </section>
</div>
    <div class="postbit" id="218894" data-post-id="218894">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/120/1440_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>ex_cldr Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Some updates to the <a href="https://github.com/elixir-cldr" rel="nofollow">Elixir CLDR</a> libraries:</p>
<ul>
<li>
<p>Improved locale parsing for language tags including complete parsing of the <a href="https://datatracker.ietf.org/doc/html/rfc6067" rel="nofollow">-u-</a> and <a href="https://datatracker.ietf.org/doc/html/rfc6497" rel="nofollow">-t-</a> extensions in <a href="https://hex.pm/packages/ex_cldr/2.23.0" rel="nofollow">ex_cldr version 2.23.0</a>. For a more accessible description see <a href="https://www.w3.org/International/multilingualweb/dublin/slides/23b-davis.pdf" rel="nofollow">this presentation</a> by Mark Davis from Google. It also adds the <code>Cldr.Language.Sigil</code> module defining <code>sigil_l</code> for defining language tags.</p>
</li>
<li>
<p>Added the <a href="https://hex.pm/packages/ex_cldr_locale_display" rel="nofollow">ex_cldr_locale_display</a> library to - you guessed it - render a language tag in a human readable format suitable for presentation in a UI.</p>
</li>
<li>
<p>Updated <a href="https://hex.pm/packages/ex_cldr_html" rel="nofollow">ex_cldr_html</a> to support producing localised <code>Phoenix.HTML.Form.select/4</code> select tags.</p>
</li>
</ul>
<h4><a name="p-218894-locale-display-with-ex_cldr_locale_display-1" class="anchor" href="#p-218894-locale-display-with-ex_cldr_locale_display-1" aria-label="Heading link" rel="nofollow"></a>Locale display with <code>ex_cldr_locale_display</code></h4>
<p>For common locales the output is as you would expect - and perhaps you’re thinking why even have a library for these?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; Cldr.display_name ~l"en"u
"English"
iex`&gt; Cldr.display_name ~l"fr"u
"French"
iex`&gt; Cldr.display_name ~l"zh"u
"Chinese"
</code></pre>
<p>Things get more interesting with combinations of languages, scrips and territories:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; Cldr.display_name ~l"en-GB"u
"British English"
iex&gt; Cldr.display_name ~l"fr-CA"u
"Canadian French"
iex&gt; Cldr.display_name ~l"zh-Hant"u
"Traditional Chinese"
iex&gt; Cldr.display_name ~l"zh-Hant" 
"Traditional Chinese (Taiwan)"
iex&gt; Cldr.display_name ~l"zh-Hans"
"Simplified Chinese (China)"
iex&gt; Cldr.display_name ~l"nl-BE"u
"Flemish"
</code></pre>
<p>And if you really want to get into the power of language tags then this example``` can be a bit mind-bending:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; Cldr.display_name ~l"fr-CA-u-ca-gregory-nu-arab-cu-usd-cf-account-ms-uksystem-t-hi-h0-hybrid"u
"Canadian French (Hybrid: Hindi, Gregorian Calendar, Accounting Currency Format, Currency: US$, Imperial Measurement System, Arabic-Indic Digits)"

iex&gt; Cldr.display_name ~l"fr-CA-u-ca-gregory-nu-arab-cu-usd-cf-account-ms-uksystem"u, locale: "zh-Hant"     
"法文（加拿大）（公曆，會計貨幣格式，貨幣：US$，英制度量單位系統，阿拉伯-印度數字）"

iex&gt; Cldr.display_name ~l"fr-CA-u-ca-gregory-nu-arab-cu-usd-cf-account-ms-uksystem"u, locale: "ar"     
"الفرنسية الكندية (التقويم الميلادي، تنسيق العملة للحسابات، العملة: US$، نظام القياس البريطاني، الأرقام العربية الهندية)"

iex&gt; Cldr.display_name ~l"fr-CA-u-ca-gregory-nu-arab-cu-usd-cf-account-ms-uksystem"u, locale: "he"
"צרפתית (קנדה) (לוח השנה הגרגוריאני, תבנית מטבע למטרות חשבונאות, מטבע:‏ US$, מערכת מדידה אימפריאלית, ספרות הודיות-ערביות)"

iex&gt; Cldr.display_name ~l"fr-CA-u-ca-gregory-nu-arab-cu-usd-cf-account-ms-uksystem"u, locale: "th"
"ฝรั่งเศส - แคนาดา (ปฏิทินเกรกอเรียน, รูปแบบสกุลเงินบัญชี, สกุลเงิน: US$, ระบบการวัดอิมพีเรียล, ตัวเลขอารบิก-อินดิก)"
</code></pre>
<p><code>ex_cldr</code> supports most of the power of language tags and during localisation will respect regional overrides, subdivisions, currencies, currency formats, unit measurement systems and so on.</p>
<h4><a name="p-218894-html-select-tags-for-locales-with-ex_cldr_html-2" class="anchor" href="#p-218894-html-select-tags-for-locales-with-ex_cldr_html-2" aria-label="Heading link" rel="nofollow"></a>HTML select tags for locales with <code>ex_cldr_html</code></h4>
<p>Providing users with a means to select their preferred locale is important for good UX and DX. With <code>Cldr.HTML.Locale.select/3</code> thats now easy:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># Select from the locales configured in `Cldr.default_backend/0` and localize them
# using the locale `Cldr.default_locale/0`
iex&gt; Cldr.HTML.Locale.select(:my_form, :locales) |&gt; Phoenix.HTML.safe_to_string()
</code></pre>
<p>Produces, when formatted:</p>
<pre data-code-wrap="html"><code class="lang-html">&lt;select id="my_form_locales" name="my_form[locales]"&gt;
	&lt;option value="ar"&gt;Arabic&lt;/option&gt;
	&lt;option value="zh-Hans"&gt;Chinese (Simplified)&lt;/option&gt;
	&lt;option value="zh-Hant"&gt;Chinese (Traditional)&lt;/option&gt;
	&lt;option value="en"&gt;English&lt;/option&gt;
	&lt;option value="he"&gt;Hebrew&lt;/option&gt;
	&lt;option value="th"&gt;Thai&lt;/option&gt;
&lt;/select&gt;
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir"># Select from the locales configured in `Cldr.default_backend/0` and localize them
# using their own locale`
iex&gt; Cldr.HTML.Locale.select(:my_form, :locales, locale: :identity) |&gt; Phoenix.HTML.safe_to_string()
</code></pre>
<p>Produces, when formatted:</p>
<pre data-code-wrap="html"><code class="lang-html">&lt;select id="my_form_locales" name="my_form[locales]"&gt;
	&lt;option value="en"&gt;English&lt;/option&gt;
	&lt;option value="he"&gt;עברית&lt;/option&gt;
	&lt;option value="ar"&gt;العربية&lt;/option&gt;
	&lt;option value="th"&gt;ไทย&lt;/option&gt;
	&lt;option value="zh-Hans"&gt;简体中文&lt;/option&gt;
	&lt;option value="zh-Hant"&gt;繁體中文&lt;/option&gt;
&lt;/select&gt;
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="218894" data-batch-url="/posts/batch_likers">
                        8
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/63">Post #62</a>
	                </div>
	            </div>
              <div id="likers-container-218894" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="218894"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #62"></div>
  </section>
</div>
    <div class="postbit" id="230195" data-post-id="230195">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/120/1440_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>ex_cldr Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a href="https://cldr.unicode.org/index/downloads/cldr-40" rel="nofollow">CLDR release 40</a> was release today by the <a href="https://home.unicode.org" rel="nofollow">Unicode Consortium</a>.</p>
<h3><a name="p-230195-cldr-40-changes-1" class="anchor" href="#p-230195-cldr-40-changes-1" aria-label="Heading link" rel="nofollow"></a>CLDR 40 Changes</h3>
<ul>
<li>Adds locales <code>sc</code>, <code>kgp</code>, <code>dsb</code>, <code>hsb</code>, <code>yrl</code></li>
<li>Add grammatical features (gender and case) to an additional 29 locales. In many languages, forming grammatical phrases requires dealing with grammatical gender and case. Without that, it can sound as bad as “on top of 3 hours” instead of “in 3 hours”. The overall goal for CLDR is to supply building blocks so that implementations of advanced message formatting can handle gender and case. <a href="https://hex.pm/packages/ex_cldr_units/3.8.0" rel="nofollow">ex_cldr_units</a> allows specifying grammatical gender and case when formatting units of measure.</li>
<li>Added or modified over 140,000 data fields</li>
</ul>
<h3><a name="p-230195-ex_cldr-library-updates-2" class="anchor" href="#p-230195-ex_cldr-library-updates-2" aria-label="Heading link" rel="nofollow"></a>Ex_CLDR library updates</h3>
<ul>
<li>
<p><a href="https://hex.pm/packages/ex_cldr/2.24.0" rel="nofollow">ex_cldr version 2.24.0</a> is updated to use CLDR 40 data and has a lot of internal refactoring to make it easier to update to new CLDR releases in the future.</p>
</li>
<li>
<p><a href="https://hex.pm/packages/ex_cldr_numbers/2.23.0" rel="nofollow">ex_cldr_numbers version 2.23.0</a> allows using any of the <a href="https://unicode.org/reports/tr35/tr35-numbers.html#Rule-Based_Number_Formatting" rel="nofollow">rules based number formats</a> when calling <code>Cldr.Number.to_string/3</code>.</p>
</li>
<li>
<p><a href="https://hex.pm/packages/ex_cldr_calendars/1.17.0" rel="nofollow">ex_cldr_calendars version 1.17.0</a> adds support for Chinese, Japanese and Korean <a href="https://github/elixir-cldr/cldr_calendars_lunisolar" rel="nofollow">lunisolar calendars</a> that will be released in the coming weeks. Early adopters can try the library now from GitHub. (documentation and testing is not complete).</p>
</li>
<li>
<p><a href="https://hex.pm/packages/ex_cldr_dates_times/2.10.0" rel="nofollow">ex_cldr_dates_times version version 2.10.0</a> adds localization in support of Chinese, Japanese and Korea calendars (era, month names, cyclic year, related gregorian year)</p>
</li>
<li>
<p><a href="https://hex.pm/packages/ex_cldr_units/3.8.0" rel="nofollow">ex_cldr_units version 3.8.0</a> adds support for grammatical features (gender and case) in the newly-supported locales.</p>
</li>
<li>
<p><a href="https://hex.pm/ex_cldr_territories/2.3.0" rel="nofollow">ex_cldr_territories version 2.3.0</a> by <a class="mention" href="/u/schultzer" rel="nofollow">@Schultzer</a> is released to support <code>ex_cldr</code> version 2.24.0.</p>
</li>
<li>
<p><a href="https://hex.pm/packages/ex_cldr_languages/0.3.0" rel="nofollow">ex_cldr_languages version 0.3.0</a> by <a class="mention" href="/u/lostkobrakai" rel="nofollow">@LostKobrakai</a>  is release to support <code>ex_cldr</code> version 2.24.0.</p>
</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="230195" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/64">Post #63</a>
	                </div>
	            </div>
              <div id="likers-container-230195" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="230195"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #63"></div>
  </section>
</div>
    <div class="postbit" id="231879" data-post-id="231879">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/120/1440_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>ex_cldr Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Its release Sunday and today <a href="https://hex.pm/packages/ex_cldr_units/3.9.0" rel="nofollow">ex_cldr_units version 3.9.0</a> is released with the following enhancements.</p>
<h3><a name="p-231879-enhancements-1" class="anchor" href="#p-231879-enhancements-1" aria-label="Heading link" rel="nofollow"></a>Enhancements</h3>
<ul>
<li>Add support for currency-based units.  This allows for calculations and formatting of units such as “$2 per gallon”. For this example, the unit would be created with <code>Cldr.Unit.new(2, "curr-usd-per-gallon")</code>. The inverse is also possible, for example:</li>
</ul>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; MyApp.Cldr.Unit.to_string(Cldr.Unit.new!(2, "curr-usd-per-gallon"))
{:ok, "$2.00 per gallon"}

iex&gt; MyApp.Cldr.Unit.to_string(Cldr.Unit.new!(2, "gallon-per-curr-usd"))
{:ok, "2 gallons per US dollar"}
</code></pre>
<ul>
<li>Add support for binary factor prefixed units. These units are factors of 1024 and include “kibi”, “mebi”, “gibi”, “tebi”, “pebi”, “exbi”, “zebi” and “yobi”. For example:</li>
</ul>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; MyApp.Cldr.Unit.to_string Cldr.Unit.new!(3, :gibibyte)
{:ok, "3 gibibytes"}
</code></pre>
<ul>
<li>Add support for integer prefixes for units. This is useful for units like “liters per 100 kilometers” or “25 calories per 100 grams”.  For example:</li>
</ul>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; MyApp.Cldr.Unit.to_string Cldr.Unit.new!(25, "calorie_per_100-gram")
{:ok, "25 calories per 100 grams"}
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="231879" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/65">Post #64</a>
	                </div>
	            </div>
              <div id="likers-container-231879" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="231879"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #64"></div>
  </section>
</div>
    <div class="postbit" id="231904" data-post-id="231904">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="slouchpie" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/slouchpie/120/34819_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  slouchpie
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="kip" data-post="65" data-topic="17350">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/48/1440_2.png" class="avatar"> kip:</div>
<blockquote>
<p><code>.Unit.to_string(Cldr.Unit.new!(2, "curr-usd-per-gallon"))</code></p>
</blockquote>
</aside>
<p>This is so crazy! I was playing with it and I noticed that not all units will work (probably “per” is being parsed). For example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex [8] &gt; Gaming.Cldr.Unit.to_string(Cldr.Unit.new!(2, "curr-usd-per-mile-per-gallon"))
** (Cldr.UnknownUnitError) Unknown unit was detected at "per_gallon"
    (ex_cldr_units 3.9.0) lib/cldr/unit.ex:637: Cldr.Unit.new!/3
</code></pre>
<p>“per” occurs twice. Although it’s strange because this works fine:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex [9] &gt; Gaming.Cldr.Unit.to_string(Cldr.Unit.new!(2, "curr-usd-per-meter-per-second"))
{:ok, "$2.00 per meter per second"}
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="231904" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/66">Post #65</a>
	                </div>
	            </div>
              <div id="likers-container-231904" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="231904"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #65"></div>
  </section>
</div>
    <div class="postbit" id="231917" data-post-id="231917">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/120/1440_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>ex_cldr Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for trying it out!  The reason the first example works, and the second doesn’t parse, is that <code>meter-per-second</code> is a built-in unit and <code>mile-per-gallon</code> isn’t.  The current implementation doesn’t support multiple instances of <code>per</code> in a compound unit definition. But … now I’ll look to making that work.</p>
<p>You can certainly do some crazy stuff, like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; u = Cldr.Unit.new!(2, "curr-usd-foot-pound-per-ampere-light-year")
#Cldr.Unit&lt;"USD_pound_foot_per_light_year_ampere", 2&gt;

iex&gt; MyApp.Cldr.Unit.to_string u
{:ok, "$2.00 pound-feet per light year-ampere"}

iex&gt; MyApp.Cldr.Unit.to_string u, style: :short, fractional_digits: 0 
{:ok, "$2 lb⋅ft/ly⋅A"}
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="231917" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/67">Post #66</a>
	                </div>
	            </div>
              <div id="likers-container-231917" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="231917"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #66"></div>
  </section>
</div>
    <div class="postbit" id="231980" data-post-id="231980">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/120/1440_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>ex_cldr Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ve published <a href="https://hex.pm/packages/ex_cldr_units/3.9.1" rel="nofollow">ex_cldr_units version 3.9.1</a> that now supports multiple <code>-per-</code> phrases in a unit definition.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; u = Cldr.Unit.new!(2, "curr-usd-per-mile-per-gallon") 
#Cldr.Unit&lt;"curr_usd_per_gallon_mile", 2&gt;
</code></pre>
<p>But you’ll notice that this resolves to <code>curr_usd_per_gallon_mile</code> since per <a href="https://unicode.org/reports/tr35/tr35-general.html#Unit_Identifiers" rel="nofollow">the specification</a>:</p>
<ul>
<li>Multiplication binds more tightly than division, so kilogram-meter-per-second-ampere is interpreted as (kg ⋅ m) / (s ⋅ a).</li>
<li>Thus if -per- occurs multiple times, each occurrence after the first is equivalent to a multiplication:
<ul>
<li>kilogram-meter-per-second-ampere ⩧ kilogram-meter-per-second-per-ampere.</li>
</ul>
</li>
</ul>
<p>And then the canonical unit sort order is applied. When output as a string:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; MyApp.Cldr.Unit.to_string u                           
{:ok, "$2.00 per gallon-mile"}
</code></pre>
<p>Which is logically consistent but maybe not what you expect.  That why there are pre-defined units like <code>meter-per-second</code>. <s>Unfortunately, <code>mile-per-gallon</code> is not currently predefined</s> It is predefined but as a compound conversion, which results in the name being resolved as above. <code>meter-per-second</code> is predefined with a single conversion factor which is why its name remains unchanged.</p>
<p>Thanks for the gentle push <a class="mention" href="/u/slouchpie" rel="nofollow">@slouchpie</a> to get this fixed, even if it doesn’t necessarily serve your purpose.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="231980" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/68">Post #67</a>
	                </div>
	            </div>
              <div id="likers-container-231980" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="231980"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #67"></div>
  </section>
</div>
    <div class="postbit" id="232030" data-post-id="232030">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="slouchpie" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/slouchpie/120/34819_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  slouchpie
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I didn’t even have a purpose! <img src="https://forum.elixirforum.com/images/emoji/apple/grinning_face_with_smiling_eyes.png?v=15" title=":grinning_face_with_smiling_eyes:" class="emoji" alt=":grinning_face_with_smiling_eyes:" loading="lazy" width="20" height="20"> I was just playing with it. For some reason, <code>mile_per_gallon</code> was returned by <code>known_units</code> in one of my projects so I tried it.</p>
<p>I think the solution is perfect though. Multiple “per” is, ultimately, linguistically ambiguous.<br>
Example: <code>x per y per z</code> can be either <code>x / (y /z) = xz / y</code> or <code>(x/y) / z = x /yz</code> .<br>
So even an implementation that rigorously adheres to the specification will be controversial for somebody’s use case.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="232030" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/69">Post #68</a>
	                </div>
	            </div>
              <div id="likers-container-232030" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="232030"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #68"></div>
  </section>
</div>
    <div class="postbit" id="237234" data-post-id="237234">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kip" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/120/1440_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kip
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>ex_cldr Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Today <a href="https://hex.pm/ex_cldr" rel="nofollow">ex_cldr</a> hit one million downloads on hex.pm.</p>
<p>I wrote the first message on this topic in 2018 so it’s been a while. And maybe it’s three enthusiasts with a non-caching CI/CD pipeline only <img src="https://forum.elixirforum.com/images/emoji/apple/grinning_face.png?v=15" title=":grinning_face:" class="emoji" alt=":grinning_face:" loading="lazy" width="20" height="20"> But it’s the most popular (by downloads) OSS library I’ve ever written. And because it’s Elixir it’s still fun!</p>
<p>Thanks to everyone who has used it, tried it, reported an issue or found a bug. The support and encouragement is much appreciated.</p>
<p>For early 2022 I’ll be launching:</p>
<ul>
<li>Chinese, Japanese and Korean <a href="https://github.com/elixir-cldr/clde_calendars_lunisolar" rel="nofollow">Lunisolar calendars</a></li>
<li>Updated <a href="https://github.com/elixir-cldr/cldr_messages" rel="nofollow">ICU Message formatter</a> with Gettext integration (due primarily to the work of <a class="mention" href="/u/maennchen" rel="nofollow">@maennchen</a>)</li>
</ul>
<p>And then in the background I’m still working on transformations and collations.</p>
<p>Here’s to an exciting 2022!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="237234" data-batch-url="/posts/batch_likers">
                        14
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/70">Post #69</a>
	                </div>
	            </div>
              <div id="likers-container-237234" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="237234"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #69"></div>
  </section>
</div>
    <div class="postbit" id="237469" data-post-id="237469">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="elimark1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/elimark1/120/25255_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  elimark1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You can explore the latest version of Mezzofanti here: <a href="https://github.com/tmbb/mezzofanti" rel="noopener nofollow ugc">https://github.com/tmbb/mezzofanti </a></p>
<p>Currently it supports only a gettext backend (that it, it supports translations supplied as gettext files, even though the messages themselves use the ICU message format).</p>
<aside class="quote no-group" data-username="kip" data-post="48" data-topic="17350">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/48/1440_2.png" class="avatar"> kip:</div>
<blockquote>
<p><code>Cldr.Message.format/2</code> operates totally at runtime, parsing and interpreting the format and returning a string</p>
</blockquote>
</aside>
<p>Currently I don’t have much use for this, but I might ad dit in the future.</p>
<p>My rationale is that it’s not possible to translate a string that isn’t a static string marked as translatable in the source, so all translatable strings should be wrapped ina ,macro and available at compile-time.</p>
<p>This is different from gettext, where one can feed it dynamic strings, which will be translated according to the <code>.po</code> files.</p>
<p>This is a requirement for packages like ecto, which can’t access the dependent application’s Gettext backend.</p>
<p>However, because my Mezzofanti library is able to translate strings in dependencies (this was actually the main design criterion for my library), being able to handle dynamic strings is not as useful.</p>
<aside class="quote no-group" data-username="kip" data-post="48" data-topic="17350">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/48/1440_2.png" class="avatar"> kip:</div>
<blockquote>
<p><code>Cldr.Message.Parser.parse/1</code> parses a format and returns list that can be serialised safely and interpreted at runtime. Translations could be stored internally in this format.</p>
</blockquote>
</aside>
<p>That is what I’m doing now. I’m currently embedding these lists in the code, but I can add them to a persistent term with little work and probably no relevant performance impact.</p>
<p>I’m not doing this right now because I’m trying to reduce the amount of moving parts, but I have plans for adding it in the future.</p>
<aside class="quote no-group" data-username="kip" data-post="48" data-topic="17350">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kip/48/1440_2.png" class="avatar"> kip:</div>
<blockquote>
<p>This is an optimisation of limited use at the moment since this doesn’t support runtime localisation.</p>
</blockquote>
</aside>
<p>I’m supplying the locale through the process dictionary.</p>
<p>This module illustrates a some interesting features (explained in the comments):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Mezzofanti.Fixtures.ExampleModule do
  use Mezzofanti
  # Not that I don't need to require or impor a Mezzofanti backend here.
  # I just use the Mezzofanti library, and once a backend is configured
  # it will automatically become aware of these messages
  # (even if the messages exist in a different application)

  def f() do
    # A simple static translation
    translate("Hello world!")
  end

  def g(guest) do
    # A translation with a variable.
    # This translation contains a context, possibly to disambiguate it
    # from a similar string which should be translated in a different way.
    # Mezzofanti will keep equal strings with different contexts separate.
    translate("Hello {guest}!", context: "a message", variables: [guest: guest])
  end

  def h(user, nr_photos) do
    # A more complex translation with two variables and plural forms.
    # It also defines a different domain.
    translate("""
    {nr_photos, plural,
      =0 {{user} didn't take any photos.}
      =1 {{user} took one photo.}
      other {{user} took # photos.}}\
    """,
      domain: "photos",
      variables: [
        user: user,
        nr_photos: nr_photos
      ])
  end
end
</code></pre>
<p>The following commands will create a <code>priv/mezofanti/</code> dir for the locale data:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">mix mezzofanti.extract
mix mezzofanti.new_locale pt-PT
mix mezzofanti.merge
</code></pre>
<p>This will result in:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">priv/
  mezzofanti/
    pt-PT/
      LC_MESSAGES/
        default.po
        photos.po
    default.pot
    photos.pot
</code></pre>
<p>The Mezzofanti and Cldr backends should be created and added to the apps’ config.</p>
<p>Mezzofanti expects a single global Mezzofanti backend, so that you can centralize the translations of several applications/dependencies in the same place (this is a quastionable choice, but again, it was the main design goal of this library).</p>
<p>Like gettext, Mezzofanti reads the locale from the process dictionary.</p>
<p>There are <code>Mezzofanti.set_locale()</code> and <code>Mezzofanti.get_locale()</code> for that.</p>
<p>And also my favourite function for testing, the function <code>Mezzofanti.with_locale(locale, func)</code>, which sets the locale, executes the <code>func</code> and then resets the old locale.</p>
<p>For example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; alias Mezzofanti.Fixtures.ExampleModule
Mezzofanti.Fixtures.ExampleModule

iex&gt; ExampleModule.f()
["Hello world!"]

iex&gt; ExampleModule.f() |&gt; to_string()
"Hello world!"

iex&gt; ExampleModule.g("tmbb") |&gt; to_string()
"Hello tmbb!"

iex&gt; ExampleModule.h("kip", 2) |&gt; to_string()
"kip took 2 photos."

iex&gt; ExampleModule.h("kip", 1) |&gt; to_string()
"kip took one photo."

iex&gt; ExampleModule.h("kip", 0) |&gt; to_string()
"kip didn't take any photos."

iex&gt; Mezzofanti.with_locale("pt-PT", fn -&gt; ExampleModule.h("kip", 0) |&gt; to_string() end)
"kip não tirou fotografias nenhumas."

iex&gt; Mezzofanti.with_locale("pt-PT", fn -&gt; ExampleModule.h("kip", 1) |&gt; to_string() end)
"kip tirou uma fotografia"

iex&gt; Mezzofanti.with_locale("pt-PT", fn -&gt; ExampleModule.h("kip", 2) |&gt; to_string() end)
"kip tirou 2 fotografias"
</code></pre>
<p>Mezzofanti also contains two “fake” locales for pseudoloalization.</p>
<p>Pseudolocalization is a process of automatically replacing latin characters by similar foreign characters (like characters that are visually similar or contain diacritics not present in English) and extending words with extra characters so that they ar longer than the originals.</p>
<p>This produces still readable strings, helps detect places where strings in your application haven’t been translated and helps detect places where you don’t have space for longer strings.</p>
<p>The “pseudo” locale provides pseudolocalization for simple text:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; Mezzofanti.with_locale("pseudo", fn -&gt; ExampleModule.h("kip", 2) |&gt; to_string() end)
"ǩıƥ~ ťøøǩ~ 2 ƥȟøťøš~~."

iex&gt; Mezzofanti.with_locale("pseudo", fn -&gt; ExampleModule.h("kip", 1) |&gt; to_string() end)
"ǩıƥ~ ťøøǩ~ øñê~ ƥȟøťø~."
</code></pre>
<p>The “pseudo_html” provides pseudolocalization for HTML text. It preserves HTML tags and HTML entities, while localizing the rest of the text.</p>
<p>In the first line below, you can see how “normal” pseudolocalization is not sufficient for HTML:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; Mezzofanti.with_locale("pseudo", fn -&gt; ExampleModule.i() |&gt; to_string() end)        
"Ťȟıš~ ɱêššàğê~~ ċøñťàıñš~~ &lt;šťȓøñğ&gt;ȟťɱĺ~~~~ ťàğš&lt;/šťȓøñğ&gt;~~~~ &amp;àɱƥ~; ñàšťÿ~ šťüƒƒ~..."

iex&gt; Mezzofanti.with_locale("pseudo_html", fn -&gt; ExampleModule.i() |&gt; to_string() end)
"Ťȟıš~ ɱêššàğê~~ ċøñťàıñš~~ &lt;strong&gt;ȟťɱĺ~ ťàğš~&lt;/strong&gt; &amp;amp; ñàšťÿ~ šťüƒƒ~..."
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="237469" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ex-cldr-common-locale-data-repository-cldr-functions-for-elixir/17350/71">Post #70</a>
	                </div>
	            </div>
              <div id="likers-container-237469" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="237469"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #70"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/17350/load_more?page=8">Load more posts (50 remaining)</a>
</div></template></turbo-stream>