mirror of
https://github.com/plausible/analytics.git
synced 2024-11-27 09:16:25 +03:00
1454 lines
100 KiB
HTML
1454 lines
100 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.31.1">
|
|
<meta name="project" content="Plausible v0.0.1">
|
|
|
|
|
|
<title>Plausible.Cldr.Currency — Plausible v0.0.1</title>
|
|
<link rel="stylesheet" href="dist/html-elixir-FM2CSD74.css" />
|
|
|
|
|
|
<script src="dist/handlebars.runtime-NWIB6V2M.js"></script>
|
|
<script src="dist/handlebars.templates-43PMFBC7.js"></script>
|
|
<script src="dist/sidebar_items-D25CDD8C.js"></script>
|
|
|
|
<script src="docs_config.js"></script>
|
|
|
|
<script async src="dist/html-L4O5OK2K.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 id="sidebar-menu" class="sidebar-button sidebar-toggle" aria-label="toggle sidebar" aria-controls="sidebar">
|
|
<i class="ri-menu-line ri-lg" title="Collapse/expand sidebar"></i>
|
|
</button>
|
|
|
|
<div class="background-layer"></div>
|
|
|
|
<nav id="sidebar" class="sidebar">
|
|
|
|
<div class="sidebar-header">
|
|
<div class="sidebar-projectInfo">
|
|
|
|
<a href="readme.html" class="sidebar-projectImage">
|
|
<img src="assets/logo.png" alt="Plausible" />
|
|
</a>
|
|
|
|
<div>
|
|
<a href="readme.html" class="sidebar-projectName" translate="no">
|
|
Plausible
|
|
</a>
|
|
<div class="sidebar-projectVersion" translate="no">
|
|
v0.0.1
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<ul id="sidebar-listNav" class="sidebar-listNav" role="tablist">
|
|
<li>
|
|
<button id="extras-list-tab-button" role="tab" data-type="extras" aria-controls="extras-tab-panel" aria-selected="true" tabindex="0">
|
|
Pages
|
|
</button>
|
|
</li>
|
|
|
|
<li>
|
|
<button id="modules-list-tab-button" role="tab" data-type="modules" aria-controls="modules-tab-panel" aria-selected="false" tabindex="-1">
|
|
Modules
|
|
</button>
|
|
</li>
|
|
|
|
|
|
<li>
|
|
<button id="tasks-list-tab-button" role="tab" data-type="tasks" aria-controls="tasks-tab-panel" aria-selected="false" tabindex="-1">
|
|
<span translate="no">Mix</span> Tasks
|
|
</button>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
<div id="extras-tab-panel" class="sidebar-tabpanel" role="tabpanel" aria-labelledby="extras-list-tab-button">
|
|
<ul id="extras-full-list" class="full-list"></ul>
|
|
</div>
|
|
|
|
<div id="modules-tab-panel" class="sidebar-tabpanel" role="tabpanel" aria-labelledby="modules-list-tab-button" hidden>
|
|
<ul id="modules-full-list" class="full-list"></ul>
|
|
</div>
|
|
|
|
|
|
<div id="tasks-tab-panel" class="sidebar-tabpanel" role="tabpanel" aria-labelledby="tasks-list-tab-button" hidden>
|
|
<ul id="tasks-full-list" class="full-list"></ul>
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
<main class="content">
|
|
<output role="status" id="toast"></output>
|
|
<div class="content-outer">
|
|
<div id="content" class="content-inner">
|
|
<div class="top-search">
|
|
<div class="search-settings">
|
|
<form class="search-bar" action="search.html">
|
|
<label class="search-label">
|
|
<span class="sr-only">Search documentation of Plausible</span>
|
|
<input name="q" type="text" class="search-input" placeholder="Search Documentation (press /)" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
|
</label>
|
|
<button type="submit" class="search-button" aria-label="Submit Search">
|
|
<i class="ri-search-2-line ri-lg" aria-hidden="true" title="Submit search"></i>
|
|
</button>
|
|
<button type="button" tabindex="-1" class="search-close-button" aria-hidden="true">
|
|
<i class="ri-close-line ri-lg" title="Cancel search"></i>
|
|
</button>
|
|
</form>
|
|
<div class="autocomplete">
|
|
</div>
|
|
<button class="icon-settings display-settings">
|
|
<i class="ri-settings-3-line"></i>
|
|
<span class="sr-only">Settings</span>
|
|
</button>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<h1>
|
|
|
|
<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>
|
|
</a>
|
|
<span class="text">Summary</span>
|
|
</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>
|
|
</a>
|
|
<span class="text">Functions</span>
|
|
</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.39.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>(),
|
|
only :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>(),
|
|
except :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/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.39.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</a>() | <a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</a>(),
|
|
only :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>(),
|
|
except :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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.39.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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="4262457337-1">%</span><span class="nc" data-group-id="4262457337-1">Cldr.Currency</span><span class="p" data-group-id="4262457337-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="4262457337-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="4262457337-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="4262457337-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="4262457337-3">%</span><span class="nc" data-group-id="4262457337-3">Cldr.Currency</span><span class="p" data-group-id="4262457337-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="4262457337-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="4262457337-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="4262457337-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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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.39.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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="6823913870-1">%</span><span class="nc" data-group-id="6823913870-1">Cldr.Currency</span><span class="p" data-group-id="6823913870-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="6823913870-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="6823913870-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="6823913870-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="6823913870-3">%</span><span class="nc" data-group-id="6823913870-3">Cldr.Currency</span><span class="p" data-group-id="6823913870-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="6823913870-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="6823913870-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="6823913870-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.16.1/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>() | <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Options</span>
|
|
</h2>
|
|
<ul><li><code class="inline">:locale</code> is any valid locale name returned by <a href="https://hexdocs.pm/ex_cldr/2.39.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.39.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <a href="https://hexdocs.pm/ex_cldr/2.39.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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Examples</span>
|
|
</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="5428253813-1">(</span><span class="s">"AUD"</span><span class="p" data-group-id="5428253813-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="5428253813-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="5428253813-3">%</span><span class="nc" data-group-id="5428253813-3">Cldr.Currency</span><span class="p" data-group-id="5428253813-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="5428253813-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="5428253813-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="5428253813-3">}</span><span class="p" data-group-id="5428253813-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="5428253813-5">(</span><span class="s">"THB"</span><span class="p" data-group-id="5428253813-5">)</span><span class="w">
|
|
</span><span class="p" data-group-id="5428253813-6">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="5428253813-7">%</span><span class="nc" data-group-id="5428253813-7">Cldr.Currency</span><span class="p" data-group-id="5428253813-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="5428253813-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="5428253813-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="5428253813-7">}</span><span class="p" data-group-id="5428253813-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.16.1/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>() | <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Options</span>
|
|
</h2>
|
|
<ul><li><code class="inline">:locale</code> is any valid locale name returned by <a href="https://hexdocs.pm/ex_cldr/2.39.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.39.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <a href="https://hexdocs.pm/ex_cldr/2.39.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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Examples</span>
|
|
</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="5967265284-1">(</span><span class="s">"AUD"</span><span class="p" data-group-id="5967265284-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="5967265284-2">%</span><span class="nc" data-group-id="5967265284-2">Cldr.Currency</span><span class="p" data-group-id="5967265284-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="5967265284-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="5967265284-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="5967265284-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="5967265284-4">(</span><span class="s">"THB"</span><span class="p" data-group-id="5967265284-4">)</span><span class="w">
|
|
</span><span class="p" data-group-id="5967265284-5">%</span><span class="nc" data-group-id="5967265284-5">Cldr.Currency</span><span class="p" data-group-id="5967265284-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="5967265284-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="5967265284-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="5967265284-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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</h2>
|
|
<ul><li><code class="inline">locale</code> is a <a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by
|
|
<a href="https://hexdocs.pm/ex_cldr/2.39.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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Examples</span>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="p" data-group-id="1249629665-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="1249629665-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="p" data-group-id="1249629665-2">(</span><span class="s">"en"</span><span class="p" data-group-id="1249629665-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_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="1249629665-3">{</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="1249629665-3">}</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="p" data-group-id="1249629665-4">(</span><span class="s">"en-AU"</span><span class="p" data-group-id="1249629665-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">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="p" data-group-id="1249629665-5">(</span><span class="s">"en-GB"</span><span class="p" data-group-id="1249629665-5">)</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.39.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</a>() | <a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</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 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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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.39.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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="p" data-group-id="5072428227-1">(</span><span class="s">"en"</span><span class="p" data-group-id="5072428227-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="5072428227-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="5072428227-3">%{</span><span class="w">
|
|
</span><span class="ss">USD</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="5072428227-4">%{</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="5072428227-4">}</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="5072428227-5">%{</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="5072428227-5">}</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="5072428227-6">%{</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="5072428227-6">}</span><span class="w">
|
|
</span><span class="p" data-group-id="5072428227-3">}</span><span class="w">
|
|
</span><span class="p" data-group-id="5072428227-2">}</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.39.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>(),
|
|
only :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>(),
|
|
except :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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.39.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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="p" data-group-id="8704766865-1">(</span><span class="s">"en"</span><span class="p" data-group-id="8704766865-1">)</span><span class="w">
|
|
</span><span class="p">=></span><span class="w"> </span><span class="p" data-group-id="8704766865-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="8704766865-3">%{</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="8704766865-3">}</span><span class="p" data-group-id="8704766865-2">}</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.39.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</a>() | <a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</a>(),
|
|
only :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/Cldr.Currency.html#t:filter/0">Cldr.Currency.filter</a>(),
|
|
except :: <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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.39.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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="p" data-group-id="8253467358-1">(</span><span class="s">"en"</span><span class="p" data-group-id="8253467358-1">)</span><span class="w">
|
|
</span><span class="p">=></span><span class="w"> </span><span class="p" data-group-id="8253467358-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="8253467358-2">}</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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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.39.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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="p" data-group-id="6498363585-1">(</span><span class="s">"en"</span><span class="p" data-group-id="6498363585-1">)</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="p" data-group-id="6498363585-2">(</span><span class="s">"en-AU"</span><span class="p" data-group-id="6498363585-2">)</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.39.2/Cldr.Locale.html#t:territory_code/0">Cldr.Locale.territory_code</a>()) => <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="2384326197-1">(</span><span class="p" data-group-id="2384326197-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.16.1/Cldr.Currency.html#t:code/0">Cldr.Currency.code</a>()) ::
|
|
{:ok, <a href="https://hexdocs.pm/ex_cldr_currencies/2.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Examples</span>
|
|
</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="p" data-group-id="7147949867-1">(</span><span class="s">"AUD"</span><span class="p" data-group-id="7147949867-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="7147949867-2">{</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="7147949867-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">known_currency_code</span><span class="p" data-group-id="7147949867-3">(</span><span class="s">"GGG"</span><span class="p" data-group-id="7147949867-3">)</span><span class="w">
|
|
</span><span class="p" data-group-id="7147949867-4">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="7147949867-5">{</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="7147949867-5">}</span><span class="p" data-group-id="7147949867-4">}</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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Examples</span>
|
|
</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="p" data-group-id="7541139982-1">(</span><span class="s">"AUD"</span><span class="p" data-group-id="7541139982-1">)</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="p" data-group-id="7541139982-2">(</span><span class="s">"GGG"</span><span class="p" data-group-id="7541139982-2">)</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="p" data-group-id="7541139982-3">(</span><span class="ss">:XCV</span><span class="p" data-group-id="7541139982-3">)</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/ex_cldr_currencies/2.16.1/Cldr.Currency.html#t:code/0">Cldr.Currency.code</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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><span class="p" data-group-id="7492318755-1">(</span><span class="p" data-group-id="7492318755-1">)</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.16.1/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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Options</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="2115815472-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="2115815472-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="2115815472-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w">
|
|
</span><span class="p" data-group-id="2115815472-3">%</span><span class="nc" data-group-id="2115815472-3">Cldr.Currency</span><span class="p" data-group-id="2115815472-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="2115815472-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="2115815472-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="2115815472-3">}</span><span class="p" data-group-id="2115815472-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="2115815472-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="2115815472-5">)</span><span class="w">
|
|
</span><span class="p" data-group-id="2115815472-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="2115815472-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="2115815472-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="2115815472-7">)</span><span class="w">
|
|
</span><span class="p" data-group-id="2115815472-8">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="2115815472-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="2115815472-9">}</span><span class="p" data-group-id="2115815472-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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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.16.1/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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Options</span>
|
|
</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.39.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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Examples</span>
|
|
</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="p" data-group-id="0243835218-1">(</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">:USD</span><span class="p" data-group-id="0243835218-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="0243835218-2">{</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="0243835218-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="p" data-group-id="0243835218-3">(</span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="ss">:USD</span><span class="p" data-group-id="0243835218-3">)</span><span class="w">
|
|
</span><span class="p" data-group-id="0243835218-4">{</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="0243835218-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="p" data-group-id="0243835218-5">(</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="p" data-group-id="0243835218-5">)</span><span class="w">
|
|
</span><span class="p" data-group-id="0243835218-6">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"美元"</span><span class="p" data-group-id="0243835218-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">pluralize</span><span class="p" data-group-id="0243835218-7">(</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="p" data-group-id="0243835218-7">)</span><span class="w">
|
|
</span><span class="p" data-group-id="0243835218-8">{</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="0243835218-8">}</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="p" data-group-id="0243835218-9">(</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="p" data-group-id="0243835218-9">)</span><span class="w">
|
|
</span><span class="p" data-group-id="0243835218-10">{</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="0243835218-10">}</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Arguments</span>
|
|
</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.39.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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Returns</span>
|
|
</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" class="hover-link">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
</a>
|
|
<span class="text">Example</span>
|
|
</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="p" data-group-id="2701198788-1">(</span><span class="s">"en"</span><span class="p" data-group-id="2701198788-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="2701198788-2">[</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="2701198788-2">]</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.31.1) for the
|
|
|
|
<a href="https://elixir-lang.org" title="Elixir" target="_blank" translate="no">Elixir programming language</a>
|
|
|
|
</p>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
|
<script>mermaid.initialize({startOnLoad: true})</script>
|
|
|
|
</body>
|
|
</html>
|