analytics/Plausible.Cldr.Number.System.html
github-merge-queue[bot] 2031bf6113 deploy: bfa01bff2a
2024-11-04 09:28:40 +00:00

766 lines
44 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.Number.System — 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-35867281.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.Number.System</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="#number_system_for/2" translate="no">number_system_for(locale, system_name)</a>
</div>
<div class="summary-synopsis"><p>Returns the actual number system from a number system type.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#number_system_from_locale/1" translate="no">number_system_from_locale(locale)</a>
</div>
<div class="summary-synopsis"><p>Returns the number system from a language tag or
locale name.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#number_system_names_for/1" translate="no">number_system_names_for(locale)</a>
</div>
<div class="summary-synopsis"><p>Returns the number systems available for a locale
or <code class="inline">{:error, message}</code> if the locale is not known.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#number_system_names_for!/1" translate="no">number_system_names_for!(locale)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#number_system_types_for/1" translate="no">number_system_types_for(locale)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#number_systems_for/1" translate="no">number_systems_for(locale)</a>
</div>
<div class="summary-synopsis"><p>Returns the number systems available for a locale
or <code class="inline">{:error, message}</code> if the locale is not known.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#number_systems_for!/1" translate="no">number_systems_for!(locale)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#number_systems_like/2" translate="no">number_systems_like(locale, number_system)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#system_name_from/2" translate="no">system_name_from(system_name, locale)</a>
</div>
<div class="summary-synopsis"><p>Returns a number system name for a given locale and number system reference.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#to_system/2" translate="no">to_system(number, system)</a>
</div>
<div class="summary-synopsis"><p>Converts a number into the representation of
a non-latin number system.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#to_system!/2" translate="no">to_system!(number, system_name)</a>
</div>
<div class="summary-synopsis"><p>Converts a number into the representation of
a non-latin number system. Returns a converted
string or raises on error.</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="number_system_for/2">
<div class="detail-header">
<a href="#number_system_for/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">number_system_for(locale, system_name)</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> number_system_for(
<a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>(),
<a href="https://hexdocs.pm/ex_cldr_numbers/2.33.1/Cldr.Number.System.html#t:system_name/0">Cldr.Number.System.system_name</a>()
) ::
{:ok, [<a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">atom</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 actual number system from a number system type.</p><ul><li><p><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/0"><code class="inline">Cldr.known_locale_names/0</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></p></li><li><p><code class="inline">system_name</code> is any number system name returned by
<a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.html#known_number_systems/0"><code class="inline">Cldr.known_number_systems/0</code></a> or a number system type
returned by <a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.html#known_number_system_types/0"><code class="inline">Cldr.known_number_system_types/0</code></a></p></li></ul><p>This function will decode a number system type into the actual
number system. If the number system provided can't be decoded
it is returned as is.</p><h2 id="number_system_for/2-examples" class="section-heading">
<a href="#number_system_for/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&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_for</span><span class="w"> </span><span class="s">&quot;th&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">:latn</span><span class="w">
</span><span class="p" data-group-id="2721239814-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="2721239814-2">%{</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;0123456789&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">type</span><span class="p">:</span><span class="w"> </span><span class="ss">:numeric</span><span class="p" data-group-id="2721239814-2">}</span><span class="p" data-group-id="2721239814-1">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_for</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">:default</span><span class="w">
</span><span class="p" data-group-id="2721239814-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="2721239814-4">%{</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;0123456789&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">type</span><span class="p">:</span><span class="w"> </span><span class="ss">:numeric</span><span class="p" data-group-id="2721239814-4">}</span><span class="p" data-group-id="2721239814-3">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_for</span><span class="w"> </span><span class="s">&quot;he&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">:traditional</span><span class="w">
</span><span class="p" data-group-id="2721239814-5">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="2721239814-6">%{</span><span class="ss">rules</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;hebrew&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">type</span><span class="p">:</span><span class="w"> </span><span class="ss">:algorithmic</span><span class="p" data-group-id="2721239814-6">}</span><span class="p" data-group-id="2721239814-5">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_for</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">:native</span><span class="w">
</span><span class="p" data-group-id="2721239814-7">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="2721239814-8">%{</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;0123456789&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">type</span><span class="p">:</span><span class="w"> </span><span class="ss">:numeric</span><span class="p" data-group-id="2721239814-8">}</span><span class="p" data-group-id="2721239814-7">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_for</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="p">,</span><span class="w"> </span><span class="ss">:finance</span><span class="w">
</span><span class="p" data-group-id="2721239814-9">{</span><span class="w">
</span><span class="ss">:error</span><span class="p">,</span><span class="w">
</span><span class="p" data-group-id="2721239814-10">{</span><span class="nc">Cldr.UnknownNumberSystemError</span><span class="p">,</span><span class="w">
</span><span class="s">&quot;The number system :finance is unknown for the locale named :en. Valid number systems are %{default: :latn, native: :latn}&quot;</span><span class="p" data-group-id="2721239814-10">}</span><span class="w">
</span><span class="p" data-group-id="2721239814-9">}</span></code></pre>
</section>
</section>
<section class="detail" id="number_system_from_locale/1">
<div class="detail-header">
<a href="#number_system_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">number_system_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">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> number_system_from_locale(<a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>()) ::
<a href="https://hexdocs.pm/ex_cldr_numbers/2.33.1/Cldr.Number.System.html#t:system_name/0">Cldr.Number.System.system_name</a>()</pre>
</div>
<p>Returns the number system from a language tag or
locale name.</p><h2 id="number_system_from_locale/1-arguments" class="section-heading">
<a href="#number_system_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 language tag returned be <a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#new/2"><code class="inline">Cldr.Locale.new/2</code></a>
or a locale name in the list 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></li></ul><h2 id="number_system_from_locale/1-returns" class="section-heading">
<a href="#number_system_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 number system name as an atom</li></ul><h2 id="number_system_from_locale/1-examples" class="section-heading">
<a href="#number_system_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&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_from_locale</span><span class="w"> </span><span class="s">&quot;en-US-u-nu-thai&quot;</span><span class="w">
</span><span class="ss">:thai</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_from_locale</span><span class="w"> </span><span class="s">&quot;en-US&quot;</span><span class="w">
</span><span class="ss">:latn</span></code></pre>
</section>
</section>
<section class="detail" id="number_system_names_for/1">
<div class="detail-header">
<a href="#number_system_names_for/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">number_system_names_for(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> number_system_names_for(<a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>()) ::
{:ok, [<a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">atom</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 number systems available for a locale
or <code class="inline">{:error, message}</code> if the locale is not known.</p><ul><li><code class="inline">locale</code> is any valid locale name returned by <a href="Plausible.Cldr.html#known_locale_names/0"><code class="inline">Plausible.Cldr.known_locale_names/0</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="Plausible.Cldr.Locale.html#new!/1"><code class="inline">Plausible.Cldr.Locale.new!/1</code></a></li></ul><h2 id="number_system_names_for/1-examples" class="section-heading">
<a href="#number_system_names_for/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&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_names_for</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="w">
</span><span class="p" data-group-id="0373524274-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="0373524274-2">[</span><span class="ss">:latn</span><span class="p" data-group-id="0373524274-2">]</span><span class="p" data-group-id="0373524274-1">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_names_for</span><span class="w"> </span><span class="s">&quot;zz&quot;</span><span class="w">
</span><span class="p" data-group-id="0373524274-3">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="0373524274-4">{</span><span class="nc">Cldr.InvalidLanguageError</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;The language </span><span class="se">\&quot;</span><span class="s">zz</span><span class="se">\&quot;</span><span class="s"> is invalid&quot;</span><span class="p" data-group-id="0373524274-4">}</span><span class="p" data-group-id="0373524274-3">}</span></code></pre>
</section>
</section>
<section class="detail" id="number_system_names_for!/1">
<div class="detail-header">
<a href="#number_system_names_for!/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">number_system_names_for!(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">
</section>
</section>
<section class="detail" id="number_system_types_for/1">
<div class="detail-header">
<a href="#number_system_types_for/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">number_system_types_for(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">
</section>
</section>
<section class="detail" id="number_systems_for/1">
<div class="detail-header">
<a href="#number_systems_for/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">number_systems_for(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> number_systems_for(<a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</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 the number systems available for a locale
or <code class="inline">{:error, message}</code> if the locale is not known.</p><ul><li><code class="inline">locale</code> is any valid locale name returned by <a href="Plausible.Cldr.html#known_locale_names/0"><code class="inline">Plausible.Cldr.known_locale_names/0</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="Plausible.Cldr.Locale.html#new!/1"><code class="inline">Plausible.Cldr.Locale.new!/1</code></a></li></ul><h2 id="number_systems_for/1-examples" class="section-heading">
<a href="#number_systems_for/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&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_systems_for</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="w">
</span><span class="p" data-group-id="1264683186-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="1264683186-2">%{</span><span class="ss">default</span><span class="p">:</span><span class="w"> </span><span class="ss">:latn</span><span class="p">,</span><span class="w"> </span><span class="ss">native</span><span class="p">:</span><span class="w"> </span><span class="ss">:latn</span><span class="p" data-group-id="1264683186-2">}</span><span class="p" data-group-id="1264683186-1">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_systems_for</span><span class="w"> </span><span class="s">&quot;th&quot;</span><span class="w">
</span><span class="p" data-group-id="1264683186-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="1264683186-4">%{</span><span class="ss">default</span><span class="p">:</span><span class="w"> </span><span class="ss">:latn</span><span class="p">,</span><span class="w"> </span><span class="ss">native</span><span class="p">:</span><span class="w"> </span><span class="ss">:thai</span><span class="p" data-group-id="1264683186-4">}</span><span class="p" data-group-id="1264683186-3">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_systems_for</span><span class="w"> </span><span class="s">&quot;zz&quot;</span><span class="w">
</span><span class="p" data-group-id="1264683186-5">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="1264683186-6">{</span><span class="nc">Cldr.InvalidLanguageError</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;The language </span><span class="se">\&quot;</span><span class="s">zz</span><span class="se">\&quot;</span><span class="s"> is invalid&quot;</span><span class="p" data-group-id="1264683186-6">}</span><span class="p" data-group-id="1264683186-5">}</span></code></pre>
</section>
</section>
<section class="detail" id="number_systems_for!/1">
<div class="detail-header">
<a href="#number_systems_for!/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">number_systems_for!(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">
</section>
</section>
<section class="detail" id="number_systems_like/2">
<div class="detail-header">
<a href="#number_systems_like/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">number_systems_like(locale, number_system)</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> number_systems_like(
<a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>(),
<a href="https://hexdocs.pm/ex_cldr_numbers/2.33.1/Cldr.Number.System.html#t:system_name/0">Cldr.Number.System.system_name</a>()
) ::
{:ok, <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">list</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>
</section>
</section>
<section class="detail" id="system_name_from/2">
<div class="detail-header">
<a href="#system_name_from/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">system_name_from(system_name, 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> system_name_from(
<a href="https://hexdocs.pm/ex_cldr_numbers/2.33.1/Cldr.Number.System.html#t:system_name/0">Cldr.Number.System.system_name</a>(),
<a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>()
) ::
{:ok, <a href="https://hexdocs.pm/ex_cldr_numbers/2.33.1/Cldr.Number.System.html#t:system_name/0">Cldr.Number.System.system_name</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 number system name for a given locale and number system reference.</p><ul><li><p><code class="inline">system_name</code> is any number system name returned by
<a href="Plausible.Cldr.html#known_number_systems/0"><code class="inline">Plausible.Cldr.known_number_systems/0</code></a> or a number system type
returned by <a href="Plausible.Cldr.html#known_number_system_types/0"><code class="inline">Plausible.Cldr.known_number_system_types/0</code></a></p></li><li><p><code class="inline">locale</code> is any valid locale name returned by <a href="Plausible.Cldr.html#known_locale_names/0"><code class="inline">Plausible.Cldr.known_locale_names/0</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="Plausible.Cldr.Locale.html#new!/1"><code class="inline">Plausible.Cldr.Locale.new!/1</code></a></p></li></ul><p>Number systems can be references in one of two ways:</p><ul><li><p>As a number system type such as :default, :native, :traditional and
:finance. This allows references to a number system for a locale in a
consistent fashion for a given use</p></li><li><p>WIth the number system name directly, such as :latn, :arab or any of the
other 70 or so</p></li></ul><p>This function dereferences the supplied <code class="inline">system_name</code> and returns the
actual system name.</p><h2 id="system_name_from/2-examples" class="section-heading">
<a href="#system_name_from/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="n">ex</span><span class="o">&gt;</span><span class="w"> </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">system_name_from</span><span class="p" data-group-id="7907787301-1">(</span><span class="ss">:default</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="p" data-group-id="7907787301-1">)</span><span class="w">
</span><span class="p" data-group-id="7907787301-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="ss">:latn</span><span class="p" data-group-id="7907787301-2">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">system_name_from</span><span class="p" data-group-id="7907787301-3">(</span><span class="s">&quot;latn&quot;</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="p" data-group-id="7907787301-3">)</span><span class="w">
</span><span class="p" data-group-id="7907787301-4">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="ss">:latn</span><span class="p" data-group-id="7907787301-4">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">system_name_from</span><span class="p" data-group-id="7907787301-5">(</span><span class="ss">:native</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="p" data-group-id="7907787301-5">)</span><span class="w">
</span><span class="p" data-group-id="7907787301-6">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="ss">:latn</span><span class="p" data-group-id="7907787301-6">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">system_name_from</span><span class="p" data-group-id="7907787301-7">(</span><span class="ss">:nope</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;en&quot;</span><span class="p" data-group-id="7907787301-7">)</span><span class="w">
</span><span class="p" data-group-id="7907787301-8">{</span><span class="w">
</span><span class="ss">:error</span><span class="p">,</span><span class="w">
</span><span class="p" data-group-id="7907787301-9">{</span><span class="nc">Cldr.UnknownNumberSystemError</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;The number system :nope is unknown&quot;</span><span class="p" data-group-id="7907787301-9">}</span><span class="w">
</span><span class="p" data-group-id="7907787301-8">}</span></code></pre><p>Note that return value is not guaranteed to be a valid
number system for the given locale as demonstrated in the third example.</p>
</section>
</section>
<section class="detail" id="to_system/2">
<div class="detail-header">
<a href="#to_system/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">to_system(number, system)</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>Converts a number into the representation of
a non-latin number system.</p><p>This function converts numbers to a known
number system only, it does not provide number
formatting.</p><ul><li><p><code class="inline">number</code> is a <code class="inline">float</code>, <code class="inline">integer</code> 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">system_name</code> is any number system name returned by
<a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.html#known_number_systems/0"><code class="inline">Cldr.known_number_systems/0</code></a> or a number system type
returned by <a href="https://hexdocs.pm/ex_cldr/2.39.2/Cldr.html#known_number_system_types/0"><code class="inline">Cldr.known_number_system_types/0</code></a></p></li></ul><p>There are two types of number systems in CLDR:</p><ul><li><p><code class="inline">:numeric</code> in which the number system defines
a direct mapping between the latin digits <code class="inline">0..9</code>
into a the number system equivalent. In this case,
<a href="#to_system/2"><code class="inline">to_system/2</code></a> invokes <a href="https://hexdocs.pm/ex_cldr_numbers/2.33.1/Cldr.Number.Transliterate.html#transliterate_digits/3"><code class="inline">Cldr.Number.Transliterate.transliterate_digits/3</code></a>
for the given number.</p></li><li><p><code class="inline">:algorithmic</code> in which the number system
does not have the same structure as the <code class="inline">:latn</code>
number system and therefore the conversion is
done algorithmically. For CLDR the algorithm
is implemented through <a href="https://hexdocs.pm/ex_cldr_numbers/2.33.1/Cldr.Rbnf.html"><code class="inline">Cldr.Rbnf</code></a> rulesets.
These rulesets are considered by CLDR to be
less rigorous than the <code class="inline">:numeric</code> number systems
and caution and testing for a specific use case
is recommended.</p></li></ul><h2 id="to_system/2-examples" class="section-heading">
<a href="#to_system/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&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">to_system</span><span class="w"> </span><span class="mi">123456</span><span class="p">,</span><span class="w"> </span><span class="ss">:hebr</span><span class="w">
</span><span class="p" data-group-id="0089538027-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;קכ״ג׳תנ״ו&quot;</span><span class="p" data-group-id="0089538027-1">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">to_system</span><span class="w"> </span><span class="mi">123</span><span class="p">,</span><span class="w"> </span><span class="ss">:hans</span><span class="w">
</span><span class="p" data-group-id="0089538027-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;一百二十三&quot;</span><span class="p" data-group-id="0089538027-2">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">to_system</span><span class="w"> </span><span class="mi">123</span><span class="p">,</span><span class="w"> </span><span class="ss">:hant</span><span class="w">
</span><span class="p" data-group-id="0089538027-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;一百二十三&quot;</span><span class="p" data-group-id="0089538027-3">}</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">to_system</span><span class="w"> </span><span class="mi">123</span><span class="p">,</span><span class="w"> </span><span class="ss">:hansfin</span><span class="w">
</span><span class="p" data-group-id="0089538027-4">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;壹佰贰拾叁&quot;</span><span class="p" data-group-id="0089538027-4">}</span></code></pre>
</section>
</section>
<section class="detail" id="to_system!/2">
<div class="detail-header">
<a href="#to_system!/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">to_system!(number, system_name)</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>Converts a number into the representation of
a non-latin number system. Returns a converted
string or raises on error.</p><ul><li><p><code class="inline">number</code> is a <code class="inline">float</code>, <code class="inline">integer</code> 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">system_name</code> is any number system name returned by
<a href="Plausible.Cldr.html#known_number_systems/0"><code class="inline">Plausible.Cldr.known_number_systems/0</code></a> or a number system type
returned by <a href="Plausible.Cldr.html#known_number_system_types/0"><code class="inline">Plausible.Cldr.known_number_system_types/0</code></a></p></li></ul><p>See <a href="#to_system/2"><code class="inline">Plausible.Cldr.Number.System.to_system/2</code></a> for further
information.</p><h2 id="to_system!/2-examples" class="section-heading">
<a href="#to_system!/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&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">to_system!</span><span class="w"> </span><span class="mi">123</span><span class="p">,</span><span class="w"> </span><span class="ss">:hans</span><span class="w">
</span><span class="s">&quot;一百二十三&quot;</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">to_system!</span><span class="w"> </span><span class="mi">123</span><span class="p">,</span><span class="w"> </span><span class="ss">:hant</span><span class="w">
</span><span class="s">&quot;一百二十三&quot;</span><span class="w">
</span><span class="gp unselectable">iex&gt; </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">to_system!</span><span class="w"> </span><span class="mi">123</span><span class="p">,</span><span class="w"> </span><span class="ss">:hansfin</span><span class="w">
</span><span class="s">&quot;壹佰贰拾叁&quot;</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>