mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 11:02:52 +03:00
736 lines
43 KiB
HTML
736 lines
43 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="generator" content="ExDoc v0.30.3">
|
|
<meta name="project" content="Plausible v0.0.1">
|
|
|
|
<title>Plausible.Cldr.Number.System — Plausible v0.0.1</title>
|
|
<link rel="stylesheet" href="dist/html-elixir-P5GXSCHE.css" />
|
|
|
|
|
|
<script src="dist/handlebars.runtime-NWIB6V2M.js"></script>
|
|
<script src="dist/handlebars.templates-NBND3S2D.js"></script>
|
|
<script src="dist/sidebar_items-C685BE87.js"></script>
|
|
|
|
<script src="docs_config.js"></script>
|
|
|
|
<script async src="dist/html-CGDDOCMI.js"></script>
|
|
|
|
|
|
</head>
|
|
<body data-type="modules" class="page-module">
|
|
<script>
|
|
|
|
try {
|
|
var settings = JSON.parse(localStorage.getItem('ex_doc:settings') || '{}');
|
|
|
|
if (settings.theme === 'dark' ||
|
|
((settings.theme === 'system' || settings.theme == null) &&
|
|
window.matchMedia('(prefers-color-scheme: dark)').matches)
|
|
) {
|
|
document.body.classList.add('dark')
|
|
}
|
|
} catch (error) { }
|
|
</script>
|
|
|
|
<div class="main">
|
|
|
|
<button class="sidebar-button sidebar-toggle" aria-label="toggle sidebar">
|
|
<i class="ri-menu-line ri-lg" title="Collapse/expand sidebar"></i>
|
|
</button>
|
|
|
|
<section class="sidebar">
|
|
<form class="sidebar-search" action="search.html">
|
|
<button type="submit" class="search-button" aria-label="Submit Search">
|
|
<i class="ri-search-2-line" aria-hidden="true" title="Submit search"></i>
|
|
</button>
|
|
<button type="button" tabindex="-1" class="search-close-button" aria-label="Cancel Search">
|
|
<i class="ri-close-line ri-lg" aria-hidden="true" title="Cancel search"></i>
|
|
</button>
|
|
<label class="search-label">
|
|
<p class="sr-only">Search</p>
|
|
<input name="q" type="text" class="search-input" placeholder="Search..." aria-label="Input your search terms" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
|
</label>
|
|
</form>
|
|
|
|
<div class="autocomplete">
|
|
<div class="autocomplete-results">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="sidebar-header">
|
|
|
|
<a href="readme.html">
|
|
<img src="assets/logo.png" alt="Plausible" class="sidebar-projectImage">
|
|
</a>
|
|
|
|
<div class="sidebar-projectDetails">
|
|
<a href="readme.html" class="sidebar-projectName" translate="no">
|
|
Plausible
|
|
</a>
|
|
<div class="sidebar-projectVersion" translate="no">
|
|
v0.0.1
|
|
</div>
|
|
</div>
|
|
<ul class="sidebar-listNav">
|
|
<li><a id="extras-list-link" href="#full-list">Pages</a></li>
|
|
|
|
<li><a id="modules-list-link" href="#full-list">Modules</a></li>
|
|
|
|
|
|
<li><a id="tasks-list-link" href="#full-list"><span translate="no">Mix</span> Tasks</a></li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="gradient"></div>
|
|
<ul id="full-list"></ul>
|
|
</section>
|
|
|
|
<section class="content">
|
|
<output role="status" id="toast"></output>
|
|
<div class="content-outer">
|
|
<div id="content" class="content-inner">
|
|
|
|
<h1>
|
|
<button class="icon-action display-settings">
|
|
<i class="ri-settings-3-line"></i>
|
|
<span class="sr-only">Settings</span>
|
|
</button>
|
|
|
|
|
|
<a href="https://github.com/plausible/analytics/blob/main/lib/plausible/cldr.ex#L1" title="View Source" class="icon-action" rel="help">
|
|
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
|
|
<span class="sr-only">View Source</span>
|
|
</a>
|
|
|
|
<span translate="no">Plausible.Cldr.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>
|
|
Summary
|
|
</a>
|
|
</h1>
|
|
<div class="summary-functions summary">
|
|
<h2>
|
|
<a href="#functions">Functions</a>
|
|
</h2>
|
|
|
|
<div class="summary-row">
|
|
<div class="summary-signature">
|
|
<a href="#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>
|
|
Functions
|
|
</a>
|
|
</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.37.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>(),
|
|
<a href="https://hexdocs.pm/ex_cldr_numbers/2.31.3/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.37.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.37.2/Cldr.LanguageTag.html"><code class="inline">Cldr.LanguageTag</code></a> struct returned by <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><code class="inline">Cldr.Locale.new!/2</code></a></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.37.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.37.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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_for</span><span class="w"> </span><span class="s">"th"</span><span class="p">,</span><span class="w"> </span><span class="ss">:latn</span><span class="w">
|
|
</span><span class="p" data-group-id="4810856665-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="4810856665-2">%{</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="s">"0123456789"</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="4810856665-2">}</span><span class="p" data-group-id="4810856665-1">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"en"</span><span class="p">,</span><span class="w"> </span><span class="ss">:default</span><span class="w">
|
|
</span><span class="p" data-group-id="4810856665-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="4810856665-4">%{</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="s">"0123456789"</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="4810856665-4">}</span><span class="p" data-group-id="4810856665-3">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"he"</span><span class="p">,</span><span class="w"> </span><span class="ss">:traditional</span><span class="w">
|
|
</span><span class="p" data-group-id="4810856665-5">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="4810856665-6">%{</span><span class="ss">rules</span><span class="p">:</span><span class="w"> </span><span class="s">"hebrew"</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="4810856665-6">}</span><span class="p" data-group-id="4810856665-5">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"en"</span><span class="p">,</span><span class="w"> </span><span class="ss">:native</span><span class="w">
|
|
</span><span class="p" data-group-id="4810856665-7">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="4810856665-8">%{</span><span class="ss">digits</span><span class="p">:</span><span class="w"> </span><span class="s">"0123456789"</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="4810856665-8">}</span><span class="p" data-group-id="4810856665-7">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"en"</span><span class="p">,</span><span class="w"> </span><span class="ss">:finance</span><span class="w">
|
|
</span><span class="p" data-group-id="4810856665-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="4810856665-10">{</span><span class="nc">Cldr.UnknownNumberSystemError</span><span class="p">,</span><span class="w">
|
|
</span><span class="s">"The number system :finance is unknown for the locale named :en. Valid number systems are %{default: :latn, native: :latn}"</span><span class="p" data-group-id="4810856665-10">}</span><span class="w">
|
|
</span><span class="p" data-group-id="4810856665-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.37.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>()) ::
|
|
<a href="https://hexdocs.pm/ex_cldr_numbers/2.31.3/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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Arguments
|
|
</a>
|
|
</h2>
|
|
<ul><li><code class="inline">locale</code> is any language tag returned be <a href="https://hexdocs.pm/ex_cldr/2.37.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.37.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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Returns
|
|
</a>
|
|
</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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_from_locale</span><span class="w"> </span><span class="s">"en-US-u-nu-thai"</span><span class="w">
|
|
</span><span class="ss">:thai</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"en-US"</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.37.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.37.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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_system_names_for</span><span class="w"> </span><span class="s">"en"</span><span class="w">
|
|
</span><span class="p" data-group-id="1395446281-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="1395446281-2">[</span><span class="ss">:latn</span><span class="p" data-group-id="1395446281-2">]</span><span class="p" data-group-id="1395446281-1">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"zz"</span><span class="w">
|
|
</span><span class="p" data-group-id="1395446281-3">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="1395446281-4">{</span><span class="nc">Cldr.InvalidLanguageError</span><span class="p">,</span><span class="w"> </span><span class="s">"The language </span><span class="se">\"</span><span class="s">zz</span><span class="se">\"</span><span class="s"> is invalid"</span><span class="p" data-group-id="1395446281-4">}</span><span class="p" data-group-id="1395446281-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.37.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.37.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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.Number.System</span><span class="o">.</span><span class="n">number_systems_for</span><span class="w"> </span><span class="s">"en"</span><span class="w">
|
|
</span><span class="p" data-group-id="1485151724-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="1485151724-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="1485151724-2">}</span><span class="p" data-group-id="1485151724-1">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"th"</span><span class="w">
|
|
</span><span class="p" data-group-id="1485151724-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="1485151724-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="1485151724-4">}</span><span class="p" data-group-id="1485151724-3">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"zz"</span><span class="w">
|
|
</span><span class="p" data-group-id="1485151724-5">{</span><span class="ss">:error</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="1485151724-6">{</span><span class="nc">Cldr.InvalidLanguageError</span><span class="p">,</span><span class="w"> </span><span class="s">"The language </span><span class="se">\"</span><span class="s">zz</span><span class="se">\"</span><span class="s"> is invalid"</span><span class="p" data-group-id="1485151724-6">}</span><span class="p" data-group-id="1485151724-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.37.2/Cldr.Locale.html#t:locale_reference/0">Cldr.Locale.locale_reference</a>(),
|
|
<a href="https://hexdocs.pm/ex_cldr_numbers/2.31.3/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#basic-types">tuple</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.31.3/Cldr.Number.System.html#t:system_name/0">Cldr.Number.System.system_name</a>(),
|
|
<a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0">Cldr.Locale.locale_name</a>() | <a href="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0">Cldr.LanguageTag.t</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 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.37.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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="n">ex</span><span class="o">></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="1482341382-1">(</span><span class="ss">:default</span><span class="p">,</span><span class="w"> </span><span class="s">"en"</span><span class="p" data-group-id="1482341382-1">)</span><span class="w">
|
|
</span><span class="p" data-group-id="1482341382-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="1482341382-2">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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="1482341382-3">(</span><span class="s">"latn"</span><span class="p">,</span><span class="w"> </span><span class="s">"en"</span><span class="p" data-group-id="1482341382-3">)</span><span class="w">
|
|
</span><span class="p" data-group-id="1482341382-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="1482341382-4">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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="1482341382-5">(</span><span class="ss">:native</span><span class="p">,</span><span class="w"> </span><span class="s">"en"</span><span class="p" data-group-id="1482341382-5">)</span><span class="w">
|
|
</span><span class="p" data-group-id="1482341382-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="1482341382-6">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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="1482341382-7">(</span><span class="ss">:nope</span><span class="p">,</span><span class="w"> </span><span class="s">"en"</span><span class="p" data-group-id="1482341382-7">)</span><span class="w">
|
|
</span><span class="p" data-group-id="1482341382-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="1482341382-9">{</span><span class="nc">Cldr.UnknownNumberSystemError</span><span class="p">,</span><span class="w"> </span><span class="s">"The number system :nope is unknown"</span><span class="p" data-group-id="1482341382-9">}</span><span class="w">
|
|
</span><span class="p" data-group-id="1482341382-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.37.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.37.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.31.3/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.31.3/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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.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="8838383319-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"קכ״ג׳תנ״ו"</span><span class="p" data-group-id="8838383319-1">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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="8838383319-2">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"一百二十三"</span><span class="p" data-group-id="8838383319-2">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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="8838383319-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"一百二十三"</span><span class="p" data-group-id="8838383319-3">}</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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="8838383319-4">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="s">"壹佰贰拾叁"</span><span class="p" data-group-id="8838383319-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">
|
|
<i class="ri-link-m" aria-hidden="true"></i>
|
|
Examples
|
|
</a>
|
|
</h2>
|
|
<pre><code class="makeup elixir" translate="no"><span class="gp unselectable">iex> </span><span class="nc">Plausible.Cldr.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">"一百二十三"</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"一百二十三"</span><span class="w">
|
|
|
|
</span><span class="gp unselectable">iex> </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">"壹佰贰拾叁"</span></code></pre>
|
|
</section>
|
|
</section>
|
|
|
|
</div>
|
|
</section>
|
|
|
|
<footer class="footer">
|
|
<p>
|
|
|
|
<span class="line">
|
|
<button class="a-main footer-button display-quick-switch" title="Search HexDocs packages">
|
|
Search HexDocs
|
|
</button>
|
|
|
|
<a href="Plausible.epub" title="ePub version">
|
|
Download ePub version
|
|
</a>
|
|
|
|
</span>
|
|
</p>
|
|
|
|
<p class="built-using">
|
|
Built using
|
|
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener" translate="no">ExDoc</a> (v0.30.3) for the
|
|
|
|
<a href="https://elixir-lang.org" title="Elixir" target="_blank" translate="no">Elixir programming language</a>
|
|
|
|
</p>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
|
<script>mermaid.initialize({startOnLoad: true})</script>
|
|
|
|
</body>
|
|
</html>
|