mirror of
https://github.com/plausible/analytics.git
synced 2024-12-29 12:33:22 +03:00
1425 lines
96 KiB
HTML
1425 lines
96 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="generator" content="ExDoc v0.30.3">
|
|
<meta name="project" content="Plausible v0.0.1">
|
|
|
|
<title>Plausible.Cldr.Currency — Plausible v0.0.1</title>
|
|
<link rel="stylesheet" href="dist/html-elixir-P5GXSCHE.css" />
|
|
|
|
|
|
<script src="dist/handlebars.runtime-NWIB6V2M.js"></script>
|
|
<script src="dist/handlebars.templates-NBND3S2D.js"></script>
|
|
<script src="dist/sidebar_items-7A47ECE0.js"></script>
|
|
|
|
<script src="docs_config.js"></script>
|
|
|
|
<script async src="dist/html-CGDDOCMI.js"></script>
|
|
|
|
|
|
</head>
|
|
<body data-type="modules" class="page-module">
|
|
<script>
|
|
|
|
try {
|
|
var settings = JSON.parse(localStorage.getItem('ex_doc:settings') || '{}');
|
|
|
|
if (settings.theme === 'dark' ||
|
|
((settings.theme === 'system' || settings.theme == null) &&
|
|
window.matchMedia('(prefers-color-scheme: dark)').matches)
|
|
) {
|
|
document.body.classList.add('dark')
|
|
}
|
|
} catch (error) { }
|
|
</script>
|
|
|
|
<div class="main">
|
|
|
|
<button class="sidebar-button sidebar-toggle" aria-label="toggle sidebar">
|
|
<i class="ri-menu-line ri-lg" title="Collapse/expand sidebar"></i>
|
|
</button>
|
|
|
|
<section class="sidebar">
|
|
<form class="sidebar-search" action="search.html">
|
|
<button type="submit" class="search-button" aria-label="Submit Search">
|
|
<i class="ri-search-2-line" aria-hidden="true" title="Submit search"></i>
|
|
</button>
|
|
<button type="button" tabindex="-1" class="search-close-button" aria-label="Cancel Search">
|
|
<i class="ri-close-line ri-lg" aria-hidden="true" title="Cancel search"></i>
|
|
</button>
|
|
<label class="search-label">
|
|
<p class="sr-only">Search</p>
|
|
<input name="q" type="text" class="search-input" placeholder="Search..." aria-label="Input your search terms" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
|
</label>
|
|
</form>
|
|
|
|
<div class="autocomplete">
|
|
<div class="autocomplete-results">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="sidebar-header">
|
|
|
|
<a href="readme.html">
|
|
<img src="assets/logo.png" alt="Plausible" class="sidebar-projectImage">
|
|
</a>
|
|
|
|
<div class="sidebar-projectDetails">
|
|
<a href="readme.html" class="sidebar-projectName" translate="no">
|
|
Plausible
|
|
</a>
|
|
<div class="sidebar-projectVersion" translate="no">
|
|
v0.0.1
|
|
</div>
|
|
</div>
|
|
<ul class="sidebar-listNav">
|
|
<li><a id="extras-list-link" href="#full-list">Pages</a></li>
|
|
|
|
<li><a id="modules-list-link" href="#full-list">Modules</a></li>
|
|
|
|
|
|
<li><a id="tasks-list-link" href="#full-list"><span translate="no">Mix</span> Tasks</a></li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="gradient"></div>
|
|
<ul id="full-list"></ul>
|
|
</section>
|
|
|
|
<section class="content">
|
|
<output role="status" id="toast"></output>
|
|
<div class="content-outer">
|
|
<div id="content" class="content-inner">
|
|
|
|
<h1>
|
|
<button class="icon-action display-settings">
|
|
<i class="ri-settings-3-line"></i>
|
|
<span class="sr-only">Settings</span>
|
|
</button>
|
|
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" title="View Source" class="icon-action" rel="help">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
<span translate="no">Plausible.Cldr.Currency</span>
|
|
<small class="app-vsn" translate="no">(Plausible v0.0.1)</small>
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
<section id="summary" class="details-list">
|
|
<h1 class="section-heading">
|
|
<a class="hover-link" href="#summary">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Summary
|
|
</a>
|
|
</h1>
|
|
<div class="summary-functions summary">
|
|
<h2>
|
|
<a href="#functions">Functions</a>
|
|
</h2>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#currencies_for_locale/3" translate="no">currencies_for_locale(locale, only \\ :all, except \\ nil)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a map of the metadata for all currencies for
|
|
a given locale.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#currencies_for_locale!/3" translate="no">currencies_for_locale!(locale, only \\ :all, except \\ nil)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a map of the metadata for all currencies for
|
|
a given locale and raises on error.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#currency_for_code/2" translate="no">currency_for_code(currency_or_currency_code, options \\ [locale: Plausible.Cldr.default_locale()])</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns the currency metadata for the requested currency code.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#currency_for_code!/2" translate="no">currency_for_code!(currency_or_currency_code, options \\ [locale: Plausible.Cldr.default_locale()])</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns the currency metadata for the requested currency code.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#currency_from_locale/1" translate="no">currency_from_locale(locale)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns the effective currency for a given locale</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#currency_history_for_locale/1" translate="no">currency_history_for_locale(language_tag)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a list of historic and the current
|
|
currency for a given locale.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#currency_strings/3" translate="no">currency_strings(locale, only \\ :all, except \\ nil)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a map that matches a currency string to a
|
|
currency code.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#currency_strings!/3" translate="no">currency_strings!(locale_name, only \\ :all, except \\ nil)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a map that matches a currency string to a
|
|
currency code or raises an exception.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#current_currency_from_locale/1" translate="no">current_currency_from_locale(locale)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns the current currency for a given locale.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#current_territory_currencies/0" translate="no">current_territory_currencies()</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a mapping from a territory code to its
|
|
current currency code.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#known_currencies/0" translate="no">known_currencies()</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>See <a href="#known_currency_codes/0"><code class="inline">Plausible.Cldr.Currency.known_currency_codes/0</code></a>.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#known_currency?/1" translate="no">known_currency?(code)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>See <a href="#known_currency_code?/1"><code class="inline">Plausible.Cldr.Currency.known_currency_code?/1</code></a>.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#known_currency_code/1" translate="no">known_currency_code(currency_code)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a 2-tuple indicating if the supplied currency code is known.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#known_currency_code?/1" translate="no">known_currency_code?(currency_code)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a boolean indicating if the supplied currency code is known.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#known_currency_codes/0" translate="no">known_currency_codes()</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a list of all known currency codes.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#new/2" translate="no">new(currency, options \\ [])</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns a <code class="inline">Currency</code> struct created from the arguments.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#pluralize/3" translate="no">pluralize(number, currency, options \\ [])</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns the appropriate currency display name for the <code class="inline">currency</code>, based
|
|
on the plural rules in effect for the <code class="inline">locale</code>.</p></div>
|
|
|
|
</div>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#strings_for_currency/2" translate="no">strings_for_currency(currency, locale)</a>
|
|
|
|
</div>
|
|
|
|
<div class="summary-synopsis"><p>Returns the strings associated with a currency
|
|
in a given locale.</p></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
|
<section id="functions" class="details-list">
|
|
<h1 class="section-heading">
|
|
<a class="hover-link" href="#functions">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Functions
|
|
</a>
|
|
</h1>
|
|
<div class="functions-list">
|
|
<section class="detail" id="currencies_for_locale/3">
|
|
|
|
<span id="currencies_for_locale/1"></span>
|
|
|
|
<span id="currencies_for_locale/2"></span>
|
|
|
|
<div class="detail-header">
|
|
<a href="#currencies_for_locale/3" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">currencies_for_locale(locale, only \\ :all, except \\ nil)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> currencies_for_locale(
|
|
<a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</a>() | <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</a>(),
|
|
only :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>(),
|
|
except :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>()
|
|
) :: {:ok, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">map</a>()} | {:error, {<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()}}</pre>
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> currencies_for_locale(
|
|
<a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</a>() | <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</a>(),
|
|
only :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>(),
|
|
except :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>()
|
|
) :: <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">map</a>() | <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">no_return</a>()</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a map of the metadata for all currencies for
|
|
a given locale.</p><h2 id="currencies_for_locale/3-arguments" class="section-heading">
|
|
<a href="#currencies_for_locale/3-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">locale</code> is any valid locale name returned by <code class="inline">MyApp.Cldr.known_locale_names/0</code>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <code class="inline">MyApp.Cldr.Locale.new!/1</code></p></li><li><p><code class="inline">currency_status</code> is <code class="inline">:all</code>, <code class="inline">:current</code>, <code class="inline">:historic</code>,
|
|
<code class="inline">unannotated</code> or <code class="inline">:tender</code>; or a list of one or more status.
|
|
The default is <code class="inline">:all</code>. See <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#currency_filter/2"><code class="inline">Cldr.Currency.currency_filter/2</code></a>.</p></li></ul><h2 id="currencies_for_locale/3-returns" class="section-heading">
|
|
<a href="#currencies_for_locale/3-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">{:ok, currency_map}</code> or</p></li><li><p><code class="inline">{:error, {exception, reason}}</code></p></li></ul><h2 id="currencies_for_locale/3-example" class="section-heading">
|
|
<a href="#currencies_for_locale/3-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<p> MyApp.Cldr.Currency.currencies_for_locale "en"
|
|
=> {:ok,
|
|
%{</p><pre><code class="makeup elixir" translate="no"><span class="w"> </span><span class="ss">FJD</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="4698877064-1">%</span><span class="nc" data-group-id="4698877064-1">Cldr.Currency</span><span class="p" data-group-id="4698877064-1">{</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="s">"FJD"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="4698877064-2">%{</span><span class="ss">one</span><span class="p">:</span><span class="w"> </span><span class="s">"Fijian dollar"</span><span class="p">,</span><span class="w"> </span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Fijian dollars"</span><span class="p" data-group-id="4698877064-2">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">from</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Fijian Dollar"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"$"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"FJD"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">true</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">to</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="w">
|
|
</span><span class="p" data-group-id="4698877064-1">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">SUR</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="4698877064-3">%</span><span class="nc" data-group-id="4698877064-3">Cldr.Currency</span><span class="p" data-group-id="4698877064-3">{</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="s">"SUR"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="4698877064-4">%{</span><span class="ss">one</span><span class="p">:</span><span class="w"> </span><span class="s">"Soviet rouble"</span><span class="p">,</span><span class="w"> </span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Soviet roubles"</span><span class="p" data-group-id="4698877064-4">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">from</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Soviet Rouble"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"SUR"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">true</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">to</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="w">
|
|
</span><span class="p" data-group-id="4698877064-3">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="n">...</span><span class="w">
|
|
</span><span class="err">}</span><span class="err">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="currencies_for_locale!/3">
|
|
|
|
<span id="currencies_for_locale!/1"></span>
|
|
|
|
<span id="currencies_for_locale!/2"></span>
|
|
|
|
<div class="detail-header">
|
|
<a href="#currencies_for_locale!/3" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">currencies_for_locale!(locale, only \\ :all, except \\ nil)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<p>Returns a map of the metadata for all currencies for
|
|
a given locale and raises on error.</p><h2 id="currencies_for_locale!/3-arguments" class="section-heading">
|
|
<a href="#currencies_for_locale!/3-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">locale</code> is any valid locale name returned by <code class="inline">MyApp.Cldr.known_locale_names/0</code>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <code class="inline">MyApp.Cldr.Locale.new!/1</code></p></li><li><p><code class="inline">currency_status</code> is <code class="inline">:all</code>, <code class="inline">:current</code>, <code class="inline">:historic</code>,
|
|
<code class="inline">unannotated</code> or <code class="inline">:tender</code>; or a list of one or more status.
|
|
The default is <code class="inline">:all</code>. See <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#currency_filter/2"><code class="inline">Cldr.Currency.currency_filter/2</code></a>.</p></li></ul><h2 id="currencies_for_locale!/3-returns" class="section-heading">
|
|
<a href="#currencies_for_locale!/3-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">{:ok, currency_map}</code> or</p></li><li><p>raises an exception</p></li></ul><h2 id="currencies_for_locale!/3-example" class="section-heading">
|
|
<a href="#currencies_for_locale!/3-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<p> MyApp.Cldr.Currency.currencies_for_locale! "en"
|
|
=> %{</p><pre><code class="makeup elixir" translate="no"><span class="ss">FJD</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="7536416629-1">%</span><span class="nc" data-group-id="7536416629-1">Cldr.Currency</span><span class="p" data-group-id="7536416629-1">{</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="s">"FJD"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="7536416629-2">%{</span><span class="ss">one</span><span class="p">:</span><span class="w"> </span><span class="s">"Fijian dollar"</span><span class="p">,</span><span class="w"> </span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Fijian dollars"</span><span class="p" data-group-id="7536416629-2">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">from</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Fijian Dollar"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"$"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"FJD"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">true</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">to</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="w">
|
|
</span><span class="p" data-group-id="7536416629-1">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">SUR</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="7536416629-3">%</span><span class="nc" data-group-id="7536416629-3">Cldr.Currency</span><span class="p" data-group-id="7536416629-3">{</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="s">"SUR"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="7536416629-4">%{</span><span class="ss">one</span><span class="p">:</span><span class="w"> </span><span class="s">"Soviet rouble"</span><span class="p">,</span><span class="w"> </span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Soviet roubles"</span><span class="p" data-group-id="7536416629-4">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">from</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Soviet Rouble"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"SUR"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">true</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">to</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="w">
|
|
</span><span class="p" data-group-id="7536416629-3">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="n">...</span></code></pre><p> }</p>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="currency_for_code/2">
|
|
|
|
<span id="currency_for_code/1"></span>
|
|
|
|
<div class="detail-header">
|
|
<a href="#currency_for_code/2" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">currency_for_code(currency_or_currency_code, options \\ [locale: Plausible.Cldr.default_locale()])</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> currency_for_code(<a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>() | <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:t/0">Cldr.Currency.t</a>(), <a href="https://hexdocs.pm/elixir/Keyword.html#t:t/0">Keyword.t</a>()) ::
|
|
{:ok, <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:t/0">Cldr.Currency.t</a>()} | {:error, {<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()}}</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns the currency metadata for the requested currency code.</p><h2 id="currency_for_code/2-arguments" class="section-heading">
|
|
<a href="#currency_for_code/2-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">currency_or_currency_code</code> is a <code class="inline">binary</code> or <code class="inline">atom</code> representation
|
|
of an ISO 4217 currency code, or a <code class="inline">%Cldr.Currency{}</code> struct.</li></ul><h2 id="currency_for_code/2-options" class="section-heading">
|
|
<a href="#currency_for_code/2-options">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Options
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">:locale</code> is any valid locale name returned by <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/1"><code class="inline">Cldr.known_locale_names/1</code></a>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><code class="inline">Cldr.Locale.new!/2</code></a></li></ul><h2 id="currency_for_code/2-returns" class="section-heading">
|
|
<a href="#currency_for_code/2-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p>A <code class="inline">{:ok, currency}</code> or</p></li><li><p><code class="inline">{:error, {exception, reason}}</code></p></li></ul><h2 id="currency_for_code/2-examples" class="section-heading">
|
|
<a href="#currency_for_code/2-examples">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">currency_for_code</span><span class="p" data-group-id="7845897851-1">(</span><span class="s">"AUD"</span><span class="p" data-group-id="7845897851-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="7845897851-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="7845897851-3">%</span><span class="nc" data-group-id="7845897851-3">Cldr.Currency</span><span class="p" data-group-id="7845897851-3">{</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="s">"AUD"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="7845897851-4">%{</span><span class="ss">one</span><span class="p">:</span><span class="w"> </span><span class="s">"Australian dollar"</span><span class="p">,</span><span class="w"> </span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Australian dollars"</span><span class="p" data-group-id="7845897851-4">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Australian Dollar"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"$"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"A$"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">true</span><span class="w">
|
|
</span><span class="p" data-group-id="7845897851-3">}</span><span class="p" data-group-id="7845897851-2">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">currency_for_code</span><span class="p" data-group-id="7845897851-5">(</span><span class="s">"THB"</span><span class="p" data-group-id="7845897851-5">)</span><span class="w">
|
|
</span><span class="p" data-group-id="7845897851-6">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="7845897851-7">%</span><span class="nc" data-group-id="7845897851-7">Cldr.Currency</span><span class="p" data-group-id="7845897851-7">{</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="s">"THB"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="7845897851-8">%{</span><span class="ss">one</span><span class="p">:</span><span class="w"> </span><span class="s">"Thai baht"</span><span class="p">,</span><span class="w"> </span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Thai baht"</span><span class="p" data-group-id="7845897851-8">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Thai Baht"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"฿"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"THB"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">true</span><span class="w">
|
|
</span><span class="p" data-group-id="7845897851-7">}</span><span class="p" data-group-id="7845897851-6">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="currency_for_code!/2">
|
|
|
|
<span id="currency_for_code!/1"></span>
|
|
|
|
<div class="detail-header">
|
|
<a href="#currency_for_code!/2" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">currency_for_code!(currency_or_currency_code, options \\ [locale: Plausible.Cldr.default_locale()])</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
<span class="note">(since 2.14.0)</span>
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> currency_for_code!(<a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>() | <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:t/0">Cldr.Currency.t</a>(), <a href="https://hexdocs.pm/elixir/Keyword.html#t:t/0">Keyword.t</a>()) ::
|
|
<a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:t/0">Cldr.Currency.t</a>() | <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">no_return</a>()</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns the currency metadata for the requested currency code.</p><h2 id="currency_for_code!/2-arguments" class="section-heading">
|
|
<a href="#currency_for_code!/2-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">currency_or_currency_code</code> is a <code class="inline">binary</code> or <code class="inline">atom</code> representation
|
|
of an ISO 4217 currency code, or a <code class="inline">%Cldr.Currency{}</code> struct.</li></ul><h2 id="currency_for_code!/2-options" class="section-heading">
|
|
<a href="#currency_for_code!/2-options">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Options
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">:locale</code> is any valid locale name returned by <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/1"><code class="inline">Cldr.known_locale_names/1</code></a>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><code class="inline">Cldr.Locale.new!/2</code></a></li></ul><h2 id="currency_for_code!/2-returns" class="section-heading">
|
|
<a href="#currency_for_code!/2-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p>A <code class="inline">t:Cldr.Current.t/0</code> or</p></li><li><p>raises an exception</p></li></ul><h2 id="currency_for_code!/2-examples" class="section-heading">
|
|
<a href="#currency_for_code!/2-examples">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">currency_for_code!</span><span class="p" data-group-id="3049891468-1">(</span><span class="s">"AUD"</span><span class="p" data-group-id="3049891468-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="3049891468-2">%</span><span class="nc" data-group-id="3049891468-2">Cldr.Currency</span><span class="p" data-group-id="3049891468-2">{</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="s">"AUD"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="3049891468-3">%{</span><span class="ss">one</span><span class="p">:</span><span class="w"> </span><span class="s">"Australian dollar"</span><span class="p">,</span><span class="w"> </span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Australian dollars"</span><span class="p" data-group-id="3049891468-3">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Australian Dollar"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"$"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"A$"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">true</span><span class="w">
|
|
</span><span class="p" data-group-id="3049891468-2">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">currency_for_code!</span><span class="p" data-group-id="3049891468-4">(</span><span class="s">"THB"</span><span class="p" data-group-id="3049891468-4">)</span><span class="w">
|
|
</span><span class="p" data-group-id="3049891468-5">%</span><span class="nc" data-group-id="3049891468-5">Cldr.Currency</span><span class="p" data-group-id="3049891468-5">{</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="s">"THB"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="3049891468-6">%{</span><span class="ss">one</span><span class="p">:</span><span class="w"> </span><span class="s">"Thai baht"</span><span class="p">,</span><span class="w"> </span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Thai baht"</span><span class="p" data-group-id="3049891468-6">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Thai Baht"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"฿"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"THB"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">true</span><span class="w">
|
|
</span><span class="p" data-group-id="3049891468-5">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="currency_from_locale/1">
|
|
|
|
<div class="detail-header">
|
|
<a href="#currency_from_locale/1" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">currency_from_locale(locale)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<p>Returns the effective currency for a given locale</p><h2 id="currency_from_locale/1-arguments" class="section-heading">
|
|
<a href="#currency_from_locale/1-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">locale</code> is a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by
|
|
<a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><code class="inline">Cldr.Locale.new!/2</code></a></li></ul><h2 id="currency_from_locale/1-returns" class="section-heading">
|
|
<a href="#currency_from_locale/1-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li>A ISO 4217 currency code as an upcased atom</li></ul><h2 id="currency_from_locale/1-examples" class="section-heading">
|
|
<a href="#currency_from_locale/1-examples">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="p" data-group-id="9964147689-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">locale</span><span class="p" data-group-id="9964147689-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Plausible.Cldr</span><span class="o">.</span><span class="n">validate_locale</span><span class="w"> </span><span class="s">"en"</span><span class="w">
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">currency_from_locale</span><span class="w"> </span><span class="n">locale</span><span class="w">
|
|
</span><span class="ss">:USD</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="p" data-group-id="9964147689-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">locale</span><span class="p" data-group-id="9964147689-2">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Plausible.Cldr</span><span class="o">.</span><span class="n">validate_locale</span><span class="w"> </span><span class="s">"en-AU"</span><span class="w">
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">currency_from_locale</span><span class="w"> </span><span class="n">locale</span><span class="w">
|
|
</span><span class="ss">:AUD</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">currency_from_locale</span><span class="w"> </span><span class="s">"en-GB"</span><span class="w">
|
|
</span><span class="ss">:GBP</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="currency_history_for_locale/1">
|
|
|
|
<div class="detail-header">
|
|
<a href="#currency_history_for_locale/1" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">currency_history_for_locale(language_tag)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> currency_history_for_locale(<a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</a>() | <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</a>()) ::
|
|
<a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">map</a>() | {:error, {<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()}}</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a list of historic and the current
|
|
currency for a given locale.</p><h2 id="currency_history_for_locale/1-arguments" class="section-heading">
|
|
<a href="#currency_history_for_locale/1-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">locale</code> is any valid locale name returned by <code class="inline">MyApp.Cldr.known_locale_names/0</code>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <code class="inline">MyApp.Cldr.Locale.new!/1</code></li></ul><h2 id="currency_history_for_locale/1-example" class="section-heading">
|
|
<a href="#currency_history_for_locale/1-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">MyApp.Cldr.Currency</span><span class="o">.</span><span class="n">currency_history_for_locale</span><span class="w"> </span><span class="s">"en"</span><span class="w">
|
|
</span><span class="p" data-group-id="6160952699-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="6160952699-2">%{</span><span class="w">
|
|
</span><span class="ss">USD</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="6160952699-3">%{</span><span class="ss">from</span><span class="p">:</span><span class="w"> </span><span class="ld">~D[1792-01-01]</span><span class="p">,</span><span class="w"> </span><span class="ss">to</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p" data-group-id="6160952699-3">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">USN</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="6160952699-4">%{</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">false</span><span class="p" data-group-id="6160952699-4">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">USS</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="6160952699-5">%{</span><span class="ss">from</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w"> </span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">false</span><span class="p">,</span><span class="w"> </span><span class="ss">to</span><span class="p">:</span><span class="w"> </span><span class="ld">~D[2014-03-01]</span><span class="p" data-group-id="6160952699-5">}</span><span class="w">
|
|
</span><span class="p" data-group-id="6160952699-2">}</span><span class="w">
|
|
</span><span class="p" data-group-id="6160952699-1">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="currency_strings/3">
|
|
|
|
<span id="currency_strings/1"></span>
|
|
|
|
<span id="currency_strings/2"></span>
|
|
|
|
<div class="detail-header">
|
|
<a href="#currency_strings/3" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">currency_strings(locale, only \\ :all, except \\ nil)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> currency_strings(
|
|
<a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</a>() | <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</a>(),
|
|
only :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>(),
|
|
except :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>()
|
|
) :: {:ok, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">map</a>()} | {:error, {<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()}}</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a map that matches a currency string to a
|
|
currency code.</p><p>A currency string is a localised name or symbol
|
|
representing a currency in a locale-specific manner.</p><h2 id="currency_strings/3-arguments" class="section-heading">
|
|
<a href="#currency_strings/3-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">locale</code> is any valid locale name returned by <code class="inline">MyApp.Cldr.known_locale_names/0</code>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <code class="inline">MyApp.Cldr.Locale.new!/1</code></p></li><li><p><code class="inline">currency_status</code> is <code class="inline">:all</code>, <code class="inline">:current</code>, <code class="inline">:historic</code>,
|
|
<code class="inline">unannotated</code> or <code class="inline">:tender</code>; or a list of one or more status.
|
|
The default is <code class="inline">:all</code>. See <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#currency_filter/2"><code class="inline">Cldr.Currency.currency_filter/2</code></a>.</p></li></ul><h2 id="currency_strings/3-returns" class="section-heading">
|
|
<a href="#currency_strings/3-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">{:ok, currency_string_map}</code> or</p></li><li><p><code class="inline">{:error, {exception, reason}}</code></p></li></ul><h2 id="currency_strings/3-example" class="section-heading">
|
|
<a href="#currency_strings/3-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="nc">MyApp.Cldr.Currency</span><span class="o">.</span><span class="n">currency_strings</span><span class="w"> </span><span class="s">"en"</span><span class="w">
|
|
</span><span class="p">=></span><span class="w"> </span><span class="p" data-group-id="2466664377-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="2466664377-2">%{</span><span class="w">
|
|
</span><span class="s">"mexican silver pesos"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:MXP</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"sudanese dinar"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:SDD</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"bad"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:BAD</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"rsd"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:RSD</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"swazi lilangeni"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:SZL</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"zairean new zaire"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:ZRN</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"guyanaese dollars"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:GYD</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"equatorial guinean ekwele"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:GQE</span><span class="p">,</span><span class="w">
|
|
</span><span class="n">...</span><span class="w">
|
|
</span><span class="p" data-group-id="2466664377-2">}</span><span class="p" data-group-id="2466664377-1">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="currency_strings!/3">
|
|
|
|
<span id="currency_strings!/1"></span>
|
|
|
|
<span id="currency_strings!/2"></span>
|
|
|
|
<div class="detail-header">
|
|
<a href="#currency_strings!/3" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">currency_strings!(locale_name, only \\ :all, except \\ nil)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> currency_strings!(
|
|
<a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</a>() | <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</a>(),
|
|
only :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>(),
|
|
except :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>()
|
|
) :: <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">map</a>() | <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">no_return</a>()</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a map that matches a currency string to a
|
|
currency code or raises an exception.</p><p>A currency string is a localised name or symbol
|
|
representing a currency in a locale-specific manner.</p><h2 id="currency_strings!/3-arguments" class="section-heading">
|
|
<a href="#currency_strings!/3-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">locale</code> is any valid locale name returned by <code class="inline">MyApp.Cldr.known_locale_names/0</code>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <code class="inline">MyApp.Cldr.Locale.new!/1</code></p></li><li><p><code class="inline">currency_status</code> is <code class="inline">:all</code>, <code class="inline">:current</code>, <code class="inline">:historic</code>,
|
|
<code class="inline">unannotated</code> or <code class="inline">:tender</code>; or a list of one or more status.
|
|
The default is <code class="inline">:all</code>. See <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#currency_filter/2"><code class="inline">Cldr.Currency.currency_filter/2</code></a>.</p></li></ul><h2 id="currency_strings!/3-returns" class="section-heading">
|
|
<a href="#currency_strings!/3-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">{:ok, currency_string_map}</code> or</p></li><li><p>raises an exception</p></li></ul><h2 id="currency_strings!/3-example" class="section-heading">
|
|
<a href="#currency_strings!/3-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="nc">MyApp.Cldr.Currency</span><span class="o">.</span><span class="n">currency_strings!</span><span class="w"> </span><span class="s">"en"</span><span class="w">
|
|
</span><span class="p">=></span><span class="w"> </span><span class="p" data-group-id="7362174379-1">%{</span><span class="w">
|
|
</span><span class="s">"mexican silver pesos"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:MXP</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"sudanese dinar"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:SDD</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"bad"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:BAD</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"rsd"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:RSD</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"swazi lilangeni"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:SZL</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"zairean new zaire"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:ZRN</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"guyanaese dollars"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:GYD</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"equatorial guinean ekwele"</span><span class="w"> </span><span class="p">=></span><span class="w"> </span><span class="ss">:GQE</span><span class="p">,</span><span class="w">
|
|
</span><span class="n">...</span><span class="w">
|
|
</span><span class="p" data-group-id="7362174379-1">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="current_currency_from_locale/1">
|
|
|
|
<div class="detail-header">
|
|
<a href="#current_currency_from_locale/1" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">current_currency_from_locale(locale)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<p>Returns the current currency for a given locale.</p><p>This function does not consider the <code class="inline">U</code> extenion
|
|
parameters <code class="inline">cu</code> or <code class="inline">rg</code>. It is recommended to us
|
|
<a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#currency_from_locale/1"><code class="inline">Cldr.Currency.currency_from_locale/1</code></a> in most
|
|
circumstances.</p><h2 id="current_currency_from_locale/1-arguments" class="section-heading">
|
|
<a href="#current_currency_from_locale/1-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">locale</code> is any valid locale name returned by <code class="inline">MyApp.Cldr.known_locale_names/0</code>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <code class="inline">MyApp.Cldr.Locale.new!/1</code></li></ul><h2 id="current_currency_from_locale/1-example" class="section-heading">
|
|
<a href="#current_currency_from_locale/1-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">MyApp.Cldr.Currency</span><span class="o">.</span><span class="n">current_currency_from_locale</span><span class="w"> </span><span class="s">"en"</span><span class="w">
|
|
</span><span class="ss">:USD</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">MyApp.Cldr.Currency</span><span class="o">.</span><span class="n">current_currency_from_locale</span><span class="w"> </span><span class="s">"en-AU"</span><span class="w">
|
|
</span><span class="ss">:AUD</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="current_territory_currencies/0">
|
|
|
|
<div class="detail-header">
|
|
<a href="#current_territory_currencies/0" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">current_territory_currencies()</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
<span class="note">(since 2.15.0)</span>
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> current_territory_currencies() :: %{
|
|
required(<a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:territory_code/0">Cldr.Locale.territory_code</a>()) => <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>()
|
|
}</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a mapping from a territory code to its
|
|
current currency code.</p><p>If a territory has no current currency (like
|
|
Antartica, territory code <code class="inline">:AQ</code>) then no
|
|
mapping is returned for that territory.</p><h2 id="current_territory_currencies/0-returns" class="section-heading">
|
|
<a href="#current_territory_currencies/0-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li>A map of <code class="inline">{territory_code => Cldr.Currency.t}</code></li></ul><h2 id="current_territory_currencies/0-example" class="section-heading">
|
|
<a href="#current_territory_currencies/0-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">current_territory_currencies</span><span class="p" data-group-id="8238685936-1">(</span><span class="p" data-group-id="8238685936-1">)</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="known_currencies/0">
|
|
|
|
<div class="detail-header">
|
|
<a href="#known_currencies/0" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">known_currencies()</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<p>See <a href="#known_currency_codes/0"><code class="inline">Plausible.Cldr.Currency.known_currency_codes/0</code></a>.</p>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="known_currency?/1">
|
|
|
|
<div class="detail-header">
|
|
<a href="#known_currency?/1" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">known_currency?(code)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<p>See <a href="#known_currency_code?/1"><code class="inline">Plausible.Cldr.Currency.known_currency_code?/1</code></a>.</p>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="known_currency_code/1">
|
|
|
|
<div class="detail-header">
|
|
<a href="#known_currency_code/1" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">known_currency_code(currency_code)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> known_currency_code(<a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>()) ::
|
|
{:ok, <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>()} | {:error, {<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()}}</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a 2-tuple indicating if the supplied currency code is known.</p><h2 id="known_currency_code/1-arguments" class="section-heading">
|
|
<a href="#known_currency_code/1-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">currency_code</code> is a <code class="inline">binary</code> or <code class="inline">atom</code> representing an ISO4217
|
|
currency code</li></ul><h2 id="known_currency_code/1-returns" class="section-heading">
|
|
<a href="#known_currency_code/1-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">{:ok, currency_code}</code> or</p></li><li><p><code class="inline">{:error, {exception, reason}}</code></p></li></ul><h2 id="known_currency_code/1-examples" class="section-heading">
|
|
<a href="#known_currency_code/1-examples">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">known_currency_code</span><span class="w"> </span><span class="s">"AUD"</span><span class="w">
|
|
</span><span class="p" data-group-id="5183618291-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="ss">:AUD</span><span class="p" data-group-id="5183618291-1">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">known_currency_code</span><span class="w"> </span><span class="s">"GGG"</span><span class="w">
|
|
</span><span class="p" data-group-id="5183618291-2">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="5183618291-3">{</span><span class="nc">Cldr.UnknownCurrencyError</span><span class="p">,</span><span class="w"> </span><span class="s">"The currency </span><span class="se">\"</span><span class="s">GGG</span><span class="se">\"</span><span class="s"> is invalid"</span><span class="p" data-group-id="5183618291-3">}</span><span class="p" data-group-id="5183618291-2">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="known_currency_code?/1">
|
|
|
|
<div class="detail-header">
|
|
<a href="#known_currency_code?/1" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">known_currency_code?(currency_code)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> known_currency_code?(<a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>()) :: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">boolean</a>()</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a boolean indicating if the supplied currency code is known.</p><h2 id="known_currency_code?/1-arguments" class="section-heading">
|
|
<a href="#known_currency_code?/1-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">currency_code</code> is a <code class="inline">binary</code> or <code class="inline">atom</code> representing an ISO4217
|
|
currency code</li></ul><h2 id="known_currency_code?/1-returns" class="section-heading">
|
|
<a href="#known_currency_code?/1-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">true</code> or <code class="inline">false</code></li></ul><h2 id="known_currency_code?/1-examples" class="section-heading">
|
|
<a href="#known_currency_code?/1-examples">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">known_currency_code?</span><span class="w"> </span><span class="s">"AUD"</span><span class="w">
|
|
</span><span class="no">true</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">known_currency_code?</span><span class="w"> </span><span class="s">"GGG"</span><span class="w">
|
|
</span><span class="no">false</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">known_currency_code?</span><span class="w"> </span><span class="ss">:XCV</span><span class="w">
|
|
</span><span class="no">false</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="known_currency_codes/0">
|
|
|
|
<div class="detail-header">
|
|
<a href="#known_currency_codes/0" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">known_currency_codes()</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> known_currency_codes() :: [<a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">atom</a>()]</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a list of all known currency codes.</p><h2 id="known_currency_codes/0-example" class="section-heading">
|
|
<a href="#known_currency_codes/0-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">known_currency_codes</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="new/2">
|
|
|
|
<span id="new/1"></span>
|
|
|
|
<div class="detail-header">
|
|
<a href="#new/2" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">new(currency, options \\ [])</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> new(<a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>(), <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">map</a>() | <a href="https://hexdocs.pm/elixir/Keyword.html#t:t/0">Keyword.t</a>()) ::
|
|
{:ok, <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#t:t/0">Cldr.Currency.t</a>()} | {:error, {<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()}}</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns a <code class="inline">Currency</code> struct created from the arguments.</p><h2 id="new/2-arguments" class="section-heading">
|
|
<a href="#new/2-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">currency</code> is a private use currency code in a format defined by
|
|
<a href="https://en.wikipedia.org/wiki/ISO_4217">ISO4217</a>
|
|
which is <code class="inline">X</code> followed by two alphanumeric characters.</p></li><li><p><code class="inline">options</code> is a map of options representing the optional elements of
|
|
the <code class="inline">Cldr.Currency.t</code> struct.</p></li></ul><h2 id="new/2-options" class="section-heading">
|
|
<a href="#new/2-options">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Options
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">:name</code> is the name of the currency. Required.</li><li><code class="inline">:digits</code> is the precision of the currency. Required.</li><li><code class="inline">:symbol</code> is the currency symbol. Optional.</li><li><code class="inline">:narrow_symbol</code> is an alternative narrow symbol. Optional.</li><li><code class="inline">:round_nearest</code> is the rounding precision such as <code class="inline">0.05</code>. Optional.</li><li><code class="inline">:alt_code</code> is an alternative currency code for application use.</li><li><code class="inline">:cash_digits</code> is the precision of the currency when used as cash. Optional.</li><li><code class="inline">:cash_rounding_nearest</code> is the rounding precision when used as cash
|
|
such as <code class="inline">0.05</code>. Optional.</li></ul><h2 id="new/2-returns" class="section-heading">
|
|
<a href="#new/2-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">{:ok, Cldr.Currency.t}</code> or</p></li><li><p><code class="inline">{:error, {exception, message}}</code></p></li></ul><h2 id="new/2-example" class="section-heading">
|
|
<a href="#new/2-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">new</span><span class="p" data-group-id="5006329568-1">(</span><span class="ss">:XAE</span><span class="p">,</span><span class="w"> </span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Custom Name"</span><span class="p">,</span><span class="w"> </span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="5006329568-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="5006329568-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="5006329568-3">%</span><span class="nc" data-group-id="5006329568-3">Cldr.Currency</span><span class="p" data-group-id="5006329568-3">{</span><span class="w">
|
|
</span><span class="ss">alt_code</span><span class="p">:</span><span class="w"> </span><span class="ss">:XAE</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">cash_rounding</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">code</span><span class="p">:</span><span class="w"> </span><span class="ss">:XAE</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">count</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="5006329568-4">%{</span><span class="ss">other</span><span class="p">:</span><span class="w"> </span><span class="s">"Custom Name"</span><span class="p" data-group-id="5006329568-4">}</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">from</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">iso_digits</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Custom Name"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">narrow_symbol</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">rounding</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">symbol</span><span class="p">:</span><span class="w"> </span><span class="s">"XAE"</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">tender</span><span class="p">:</span><span class="w"> </span><span class="no">false</span><span class="p">,</span><span class="w">
|
|
</span><span class="ss">to</span><span class="p">:</span><span class="w"> </span><span class="no">nil</span><span class="w">
|
|
</span><span class="p" data-group-id="5006329568-3">}</span><span class="p" data-group-id="5006329568-2">}</span><span class="w">
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">MyApp.Cldr.Currency</span><span class="o">.</span><span class="n">new</span><span class="p" data-group-id="5006329568-5">(</span><span class="ss">:XAH</span><span class="p">,</span><span class="w"> </span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"Custom Name"</span><span class="p" data-group-id="5006329568-5">)</span><span class="w">
|
|
</span><span class="p" data-group-id="5006329568-6">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="s">"Required options are missing. Required options are [:name, :digits]"</span><span class="p" data-group-id="5006329568-6">}</span><span class="w">
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">new</span><span class="p" data-group-id="5006329568-7">(</span><span class="ss">:XAE</span><span class="p">,</span><span class="w"> </span><span class="ss">name</span><span class="p">:</span><span class="w"> </span><span class="s">"XAE"</span><span class="p">,</span><span class="w"> </span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p" data-group-id="5006329568-7">)</span><span class="w">
|
|
</span><span class="p" data-group-id="5006329568-8">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="5006329568-9">{</span><span class="nc">Cldr.CurrencyAlreadyDefined</span><span class="p">,</span><span class="w"> </span><span class="s">"Currency :XAE is already defined."</span><span class="p" data-group-id="5006329568-9">}</span><span class="p" data-group-id="5006329568-8">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="pluralize/3">
|
|
|
|
<span id="pluralize/2"></span>
|
|
|
|
<div class="detail-header">
|
|
<a href="#pluralize/3" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">pluralize(number, currency, options \\ [])</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<div class="specs">
|
|
|
|
<pre translate="no"><span class="attribute">@spec</span> pluralize(<a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">pos_integer</a>(), <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">atom</a>(), <a href="https://hexdocs.pm/elixir/Keyword.html#t:t/0">Keyword.t</a>()) ::
|
|
{:ok, <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()} | {:error, {<a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">module</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()}}</pre>
|
|
|
|
</div>
|
|
|
|
<p>Returns the appropriate currency display name for the <code class="inline">currency</code>, based
|
|
on the plural rules in effect for the <code class="inline">locale</code>.</p><h2 id="pluralize/3-arguments" class="section-heading">
|
|
<a href="#pluralize/3-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">number</code> is an integer, float or <a href="https://hexdocs.pm/decimal/2.1.1/Decimal.html"><code class="inline">Decimal</code></a></p></li><li><p><code class="inline">currency</code> is any currency returned by <a href="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#known_currencies/0"><code class="inline">Cldr.Currency.known_currencies/0</code></a></p></li><li><p><code class="inline">options</code> is a keyword list of options</p></li></ul><h2 id="pluralize/3-options" class="section-heading">
|
|
<a href="#pluralize/3-options">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Options
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">locale</code> is any valid locale name returned by <code class="inline">MyApp.Cldr.known_locale_names/0</code>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <code class="inline">MyApp.Cldr.Locale.new!/1</code>. The
|
|
default is <a href="Plausible.Cldr.html#get_locale/0"><code class="inline">Plausible.Cldr.get_locale/0</code></a></li></ul><h2 id="pluralize/3-returns" class="section-heading">
|
|
<a href="#pluralize/3-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">{:ok, plural_string}</code> or</p></li><li><p><code class="inline">{:error, {exception, message}}</code></p></li></ul><h2 id="pluralize/3-examples" class="section-heading">
|
|
<a href="#pluralize/3-examples">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">pluralize</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">:USD</span><span class="w">
|
|
</span><span class="p" data-group-id="4229076602-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"US dollar"</span><span class="p" data-group-id="4229076602-1">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">pluralize</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="ss">:USD</span><span class="w">
|
|
</span><span class="p" data-group-id="4229076602-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"US dollars"</span><span class="p" data-group-id="4229076602-2">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">pluralize</span><span class="w"> </span><span class="mi">12</span><span class="p">,</span><span class="w"> </span><span class="ss">:USD</span><span class="p">,</span><span class="w"> </span><span class="ss">locale</span><span class="p">:</span><span class="w"> </span><span class="s">"zh"</span><span class="w">
|
|
</span><span class="p" data-group-id="4229076602-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"美元"</span><span class="p" data-group-id="4229076602-3">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">pluralize</span><span class="w"> </span><span class="mi">12</span><span class="p">,</span><span class="w"> </span><span class="ss">:USD</span><span class="p">,</span><span class="w"> </span><span class="ss">locale</span><span class="p">:</span><span class="w"> </span><span class="s">"fr"</span><span class="w">
|
|
</span><span class="p" data-group-id="4229076602-4">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"dollars des États-Unis"</span><span class="p" data-group-id="4229076602-4">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Currency</span><span class="o">.</span><span class="n">pluralize</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">:USD</span><span class="p">,</span><span class="w"> </span><span class="ss">locale</span><span class="p">:</span><span class="w"> </span><span class="s">"fr"</span><span class="w">
|
|
</span><span class="p" data-group-id="4229076602-5">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"dollar des États-Unis"</span><span class="p" data-group-id="4229076602-5">}</span></code></pre>
|
|
</section>
|
|
</section>
|
|
<section class="detail" id="strings_for_currency/2">
|
|
|
|
<div class="detail-header">
|
|
<a href="#strings_for_currency/2" class="detail-link" title="Link to this function">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
<span class="sr-only">Link to this function</span>
|
|
</a>
|
|
<h1 class="signature" translate="no">strings_for_currency(currency, locale)</h1>
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" class="icon-action" rel="help" title="View Source">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
|
|
</div>
|
|
|
|
<section class="docstring">
|
|
|
|
<p>Returns the strings associated with a currency
|
|
in a given locale.</p><h2 id="strings_for_currency/2-arguments" class="section-heading">
|
|
<a href="#strings_for_currency/2-arguments">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><p><code class="inline">currency</code> is an ISO4217 currency code</p></li><li><p><code class="inline">locale</code> is any valid locale name returned by <code class="inline">MyApp.Cldr.known_locale_names/0</code>
|
|
or a <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <code class="inline">MyApp.Cldr.Locale.new!/1</code></p></li></ul><h2 id="strings_for_currency/2-returns" class="section-heading">
|
|
<a href="#strings_for_currency/2-returns">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</h2>
|
|
<ul><li><p>A list of strings or</p></li><li><p><code class="inline">{:error, {exception, reason}}</code></p></li></ul><h2 id="strings_for_currency/2-example" class="section-heading">
|
|
<a href="#strings_for_currency/2-example">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Example
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">MyApp.Cldr.Currency</span><span class="o">.</span><span class="n">strings_for_currency</span><span class="w"> </span><span class="ss">:AUD</span><span class="p">,</span><span class="w"> </span><span class="s">"en"</span><span class="w">
|
|
</span><span class="p" data-group-id="3427810148-1">[</span><span class="s">"a$"</span><span class="p">,</span><span class="w"> </span><span class="s">"australian dollars"</span><span class="p">,</span><span class="w"> </span><span class="s">"aud"</span><span class="p">,</span><span class="w"> </span><span class="s">"australian dollar"</span><span class="p" data-group-id="3427810148-1">]</span></code></pre>
|
|
</section>
|
|
</section>
|
|
|
|
</div>
|
|
</section>
|
|
|
|
<footer class="footer">
|
|
<p>
|
|
|
|
<span class="line">
|
|
<button class="a-main footer-button display-quick-switch" title="Search HexDocs packages">
|
|
Search HexDocs
|
|
</button>
|
|
|
|
<a href="Plausible.epub" title="ePub version">
|
|
Download ePub version
|
|
</a>
|
|
|
|
</span>
|
|
</p>
|
|
|
|
<p class="built-using">
|
|
Built using
|
|
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener" translate="no">ExDoc</a> (v0.30.3) for the
|
|
|
|
<a href="https://elixir-lang.org" title="Elixir" target="_blank" translate="no">Elixir programming language</a>
|
|
|
|
</p>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
|
<script>mermaid.initialize({startOnLoad: true})</script>
|
|
|
|
</body>
|
|
</html>
|