2023-07-12 11:28:07 +03:00
<!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" >
2023-07-25 10:58:48 +03:00
< meta name = "generator" content = "ExDoc v0.30.3" >
2023-07-12 11:28:07 +03:00
< meta name = "project" content = "Plausible v0.0.1" >
< title > Plausible.Cldr.Locale — Plausible v0.0.1< / title >
2023-07-25 10:58:48 +03:00
< link rel = "stylesheet" href = "dist/html-elixir-P5GXSCHE.css" / >
2023-07-12 11:28:07 +03:00
< script src = "dist/handlebars.runtime-NWIB6V2M.js" > < / script >
2023-07-25 10:58:48 +03:00
< script src = "dist/handlebars.templates-NBND3S2D.js" > < / script >
2023-08-08 15:50:05 +03:00
< script src = "dist/sidebar_items-3458A8D4.js" > < / script >
2023-07-12 11:28:07 +03:00
< script src = "docs_config.js" > < / script >
2023-07-25 10:58:48 +03:00
< script async src = "dist/html-CGDDOCMI.js" > < / script >
2023-07-12 11:28:07 +03:00
< / 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.Locale< / span >
< small class = "app-vsn" translate = "no" > (Plausible v0.0.1)< / small >
< / h1 >
< section id = "moduledoc" >
< p > Backend module that provides functions
to define new locales and display human-readable
locale names for presentation purposes.< / p >
< / section >
< 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 >
2023-07-25 10:58:48 +03:00
Summary
2023-07-12 11:28:07 +03:00
< / a >
< / h1 >
< div class = "summary-functions summary" >
< h2 >
< a href = "#functions" > Functions< / a >
< / h2 >
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#fallback_locale_names/1" translate = "no" > fallback_locale_names(locale)< / a >
< / div >
< div class = "summary-synopsis" > < p > Returns the list of fallback locale names, starting
with the provided locale name.< / p > < / div >
< / div >
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#fallback_locales/1" translate = "no" > fallback_locales(locale)< / a >
< / div >
< div class = "summary-synopsis" > < p > Returns the list of fallback locales, starting
with the provided locale name.< / p > < / div >
< / div >
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#locale_for_territory/1" translate = "no" > locale_for_territory(territory)< / a >
< / div >
< div class = "summary-synopsis" > < p > Returns the " best fit" locale for a given territory.< / p > < / div >
< / div >
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#locale_from_host/2" translate = "no" > locale_from_host(host, options \\ [])< / a >
< / div >
< div class = "summary-synopsis" > < p > Returns a " best fit" locale for a host name.< / p > < / div >
< / div >
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#new/1" translate = "no" > new(locale_name)< / a >
< / div >
< / div >
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#new!/1" translate = "no" > new!(locale_name)< / a >
< / div >
< / div >
2023-07-24 12:33:21 +03:00
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#script_direction_from_locale/1" translate = "no" > script_direction_from_locale(locale)< / a >
< / div >
< div class = "summary-synopsis" > < p > Returns the script direction for a locale.< / p > < / div >
< / div >
2023-07-12 11:28:07 +03:00
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#territory_from_host/1" translate = "no" > territory_from_host(host)< / a >
< / div >
< div class = "summary-synopsis" > < p > Returns the last segment of a host that might
be a territory.< / p > < / div >
< / div >
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#territory_from_locale/1" translate = "no" > territory_from_locale(locale)< / a >
< / div >
< div class = "summary-synopsis" > < p > Returns the territory from a language tag or
locale name.< / p > < / div >
< / div >
< div class = "summary-row" >
< div class = "summary-signature" >
< a href = "#timezone_from_locale/1" translate = "no" > timezone_from_locale(locale)< / a >
< / div >
< div class = "summary-synopsis" > < p > Returns the time zone from a language tag or
locale name.< / 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
2023-07-25 10:58:48 +03:00
< / a >
2023-07-12 11:28:07 +03:00
< / h1 >
< div class = "functions-list" >
< section class = "detail" id = "fallback_locale_names/1" >
< div class = "detail-header" >
< a href = "#fallback_locale_names/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" > fallback_locale_names(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.26.0)< / span >
< / div >
< section class = "docstring" >
< div class = "specs" >
2023-07-24 12:33:21 +03:00
< pre translate = "no" > < span class = "attribute" > @spec< / span > fallback_locale_names(< a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0" > Cldr.LanguageTag.t< / a > () | < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_reference/0" > Cldr.Locale.locale_reference< / a > ()) ::
{:ok, [< a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0" > Cldr.Locale.locale_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 >
2023-07-12 11:28:07 +03:00
< / div >
< p > Returns the list of fallback locale names, starting
with the provided locale name.< / p > < p > Fallbacks are a list of locate names which can
be used to resolve translation or other localization
data if such localised data does not exist for
2023-07-24 12:33:21 +03:00
this specific locale..< / p > < h2 id = "fallback_locale_names/1-arguments" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#fallback_locale_names/1-arguments" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Arguments
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < code class = "inline" > locale_name< / code > is any locale name returned by
< a href = "Plausible.Cldr.html#known_locale_names/0" > < code class = "inline" > Plausible.Cldr.known_locale_names/0< / code > < / a > < / li > < / ul > < h2 id = "fallback_locale_names/1-returns" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#fallback_locale_names/1-returns" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Returns
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < p > < code class = "inline" > {:ok, list_of_locale_names}< / code > or< / p > < / li > < li > < p > < code class = "inline" > {:error, {exception, reason}}< / code > < / p > < / li > < / ul > < h2 id = "fallback_locale_names/1-examples" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#fallback_locale_names/1-examples" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Examples
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
2023-08-09 13:47:49 +03:00
< pre > < code class = "makeup elixir" translate = "no" > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > fallback_locale_names< / span > < span class = "p" data-group-id = "1615645370-1" > (< / span > < span class = "ss" > :" fr-CA" < / span > < span class = "p" data-group-id = "1615645370-1" > )< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "1615645370-2" > {< / span > < span class = "ss" > :ok< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "1615645370-3" > [< / span > < span class = "ss" > :" fr-CA" < / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "ss" > :fr< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "ss" > :und< / span > < span class = "p" data-group-id = "1615645370-3" > ]< / span > < span class = "p" data-group-id = "1615645370-2" > }< / span > < span class = "w" >
2023-07-12 11:28:07 +03:00
< / span > < span class = "c1" > # Fallbacks are typically formed by progressively< / span > < span class = "w" >
< / span > < span class = "c1" > # stripping variant, territory and script from the< / span > < span class = "w" >
< / span > < span class = "c1" > # given locale name. But not always - there are< / span > < span class = "w" >
< / span > < span class = "c1" > # certain fallbacks that take a different path.< / span > < span class = "w" >
2023-08-09 13:47:49 +03:00
< / span > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > fallback_locale_names< / span > < span class = "p" data-group-id = "1615645370-4" > (< / span > < span class = "ss" > :nb< / span > < span class = "p" data-group-id = "1615645370-4" > )< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "1615645370-5" > {< / span > < span class = "ss" > :ok< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "1615645370-6" > [< / span > < span class = "ss" > :nb< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "ss" > :no< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "ss" > :und< / span > < span class = "p" data-group-id = "1615645370-6" > ]< / span > < span class = "p" data-group-id = "1615645370-5" > }< / span > < / code > < / pre >
2023-07-12 11:28:07 +03:00
< / section >
< / section >
< section class = "detail" id = "fallback_locales/1" >
< div class = "detail-header" >
< a href = "#fallback_locales/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" > fallback_locales(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.26.0)< / span >
< / div >
< section class = "docstring" >
< div class = "specs" >
2023-07-24 12:33:21 +03:00
< pre translate = "no" > < span class = "attribute" > @spec< / span > fallback_locales(< a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0" > Cldr.LanguageTag.t< / a > () | < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_reference/0" > Cldr.Locale.locale_reference< / a > ()) ::
{:ok, [< a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0" > Cldr.LanguageTag.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 >
2023-07-12 11:28:07 +03:00
< / div >
< p > Returns the list of fallback locales, starting
with the provided locale name.< / p > < p > Fallbacks are a list of locate names which can
be used to resolve translation or other localization
data if such localised data does not exist for
2023-07-24 12:33:21 +03:00
this specific locale.< / p > < h2 id = "fallback_locales/1-arguments" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#fallback_locales/1-arguments" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Arguments
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < code class = "inline" > locale_name< / code > is any locale name returned by
< a href = "Plausible.Cldr.html#known_locale_names/0" > < code class = "inline" > Plausible.Cldr.known_locale_names/0< / code > < / a > < / li > < / ul > < h2 id = "fallback_locales/1-returns" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#fallback_locales/1-returns" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Returns
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < p > < code class = "inline" > {:ok, list_of_locales}< / code > or< / p > < / li > < li > < p > < code class = "inline" > {:error, {exception, reason}}< / code > < / p > < / li > < / ul > < h2 id = "fallback_locales/1-examples" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#fallback_locales/1-examples" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Examples
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
2023-08-09 13:47:49 +03:00
< pre > < code class = "makeup elixir" translate = "no" > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > fallback_locales< / span > < span class = "p" data-group-id = "9619455072-1" > (< / span > < span class = "ss" > :" fr-CA" < / span > < span class = "p" data-group-id = "9619455072-1" > )< / span > < span class = "w" >
< / span > < span class = "p" > => < / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-2" > {< / span > < span class = "ss" > :ok< / span > < span class = "p" > ,< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "9619455072-3" > [< / span > < span class = "p" data-group-id = "9619455072-4" > #< / span > < span class = "nc" data-group-id = "9619455072-4" > Cldr.LanguageTag< / span > < span class = "p" data-group-id = "9619455072-4" > < < / span > < span class = "n" > fr< / span > < span class = "o" > -< / span > < span class = "nc" > CA< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-5" > [< / span > < span class = "n" > validated< / span > < span class = "p" data-group-id = "9619455072-5" > ]< / span > < span class = "p" data-group-id = "9619455072-4" > > < / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-6" > #< / span > < span class = "nc" data-group-id = "9619455072-6" > Cldr.LanguageTag< / span > < span class = "p" data-group-id = "9619455072-6" > < < / span > < span class = "n" > fr< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-7" > [< / span > < span class = "n" > validated< / span > < span class = "p" data-group-id = "9619455072-7" > ]< / span > < span class = "p" data-group-id = "9619455072-6" > > < / span > < span class = "p" > ,< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "9619455072-8" > #< / span > < span class = "nc" data-group-id = "9619455072-8" > Cldr.LanguageTag< / span > < span class = "p" data-group-id = "9619455072-8" > < < / span > < span class = "n" > und< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-9" > [< / span > < span class = "n" > validated< / span > < span class = "p" data-group-id = "9619455072-9" > ]< / span > < span class = "p" data-group-id = "9619455072-8" > > < / span > < span class = "p" data-group-id = "9619455072-3" > ]< / span > < span class = "p" data-group-id = "9619455072-2" > }< / span > < span class = "w" >
2023-07-12 11:28:07 +03:00
< / span > < span class = "c1" > # Fallbacks are typically formed by progressively< / span > < span class = "w" >
< / span > < span class = "c1" > # stripping variant, territory and script from the< / span > < span class = "w" >
< / span > < span class = "c1" > # given locale name. But not always - there are< / span > < span class = "w" >
< / span > < span class = "c1" > # certain fallbacks that take a different path.< / span > < span class = "w" >
2023-08-09 13:47:49 +03:00
< / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > fallback_locales< / span > < span class = "p" data-group-id = "9619455072-10" > (< / span > < span class = "ss" > :nb< / span > < span class = "p" data-group-id = "9619455072-10" > )< / span > < span class = "p" > )< / span > < span class = "w" >
< / span > < span class = "p" > => < / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-11" > {< / span > < span class = "ss" > :ok< / span > < span class = "p" > ,< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "9619455072-12" > [< / span > < span class = "p" data-group-id = "9619455072-13" > #< / span > < span class = "nc" data-group-id = "9619455072-13" > Cldr.LanguageTag< / span > < span class = "p" data-group-id = "9619455072-13" > < < / span > < span class = "n" > nb< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-14" > [< / span > < span class = "n" > validated< / span > < span class = "p" data-group-id = "9619455072-14" > ]< / span > < span class = "p" data-group-id = "9619455072-13" > > < / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-15" > #< / span > < span class = "nc" data-group-id = "9619455072-15" > Cldr.LanguageTag< / span > < span class = "p" data-group-id = "9619455072-15" > < < / span > < span class = "n" > no< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-16" > [< / span > < span class = "n" > validated< / span > < span class = "p" data-group-id = "9619455072-16" > ]< / span > < span class = "p" data-group-id = "9619455072-15" > > < / span > < span class = "p" > ,< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "9619455072-17" > #< / span > < span class = "nc" data-group-id = "9619455072-17" > Cldr.LanguageTag< / span > < span class = "p" data-group-id = "9619455072-17" > < < / span > < span class = "n" > und< / span > < span class = "w" > < / span > < span class = "p" data-group-id = "9619455072-18" > [< / span > < span class = "n" > validated< / span > < span class = "p" data-group-id = "9619455072-18" > ]< / span > < span class = "p" data-group-id = "9619455072-17" > > < / span > < span class = "p" data-group-id = "9619455072-12" > ]< / span > < span class = "p" data-group-id = "9619455072-11" > }< / span > < / code > < / pre >
2023-07-12 11:28:07 +03:00
< / section >
< / section >
< section class = "detail" id = "locale_for_territory/1" >
< div class = "detail-header" >
< a href = "#locale_for_territory/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" > locale_for_territory(territory)< / 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.26.0)< / span >
< / div >
< section class = "docstring" >
< div class = "specs" >
2023-07-24 12:33:21 +03:00
< pre translate = "no" > < span class = "attribute" > @spec< / span > locale_for_territory(< a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:territory_code/0" > Cldr.Locale.territory_code< / a > ()) ::
{:ok, < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0" > Cldr.LanguageTag.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 >
2023-07-12 11:28:07 +03:00
< / div >
< p > Returns the " best fit" locale for a given territory.< / p > < p > Using the population percentage data from CLDR, the
language most commonly spoken in the given territory
is used to form a locale name which is then validated
against the given backend.< / p > < p > First a territory-specific locale is validated and if
that fails, the base language only is validate.< / p > < p > For example, if the territory is < code class = "inline" > AU< / code > then then the
language most spoken is " en" . First, the locale " en-AU"
is validated and if that fails, " en" is validated.< / p > < h2 id = "locale_for_territory/1-arguments" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#locale_for_territory/1-arguments" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Arguments
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < code class = "inline" > territory< / code > is any ISO 3166 Alpha-2 territory
2023-07-24 12:33:21 +03:00
code that can be validated by < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#validate_territory/1" > < code class = "inline" > Cldr.validate_territory/1< / code > < / a > < / li > < / ul > < h2 id = "locale_for_territory/1-returns" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#locale_for_territory/1-returns" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Returns
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < p > < code class = "inline" > {:ok, language_tag}< / code > or< / p > < / li > < li > < p > < code class = "inline" > {:error, {exception, reason}}< / code > < / p > < / li > < / ul > < h2 id = "locale_for_territory/1-examples" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#locale_for_territory/1-examples" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Examples
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< p > iex> Plausible.Cldr.Locale.locale_for_territory(:AU)
Elixir.Plausible.Cldr.validate_locale(:" en-AU" )< / p > < p > iex> Plausible.Cldr.Locale.locale_for_territory(:US)
Elixir.Plausible.Cldr.validate_locale(:" en-US" )< / p > < p > iex> Plausible.Cldr.Locale.locale_for_territory(:ZZ)
{:error, {Cldr.UnknownTerritoryError, " The territory :ZZ is unknown" }}< / p >
< / section >
< / section >
< section class = "detail" id = "locale_from_host/2" >
< span id = "locale_from_host/1" > < / span >
< div class = "detail-header" >
< a href = "#locale_from_host/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" > locale_from_host(host, 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 >
< span class = "note" > (since 2.26.0)< / span >
< / div >
< section class = "docstring" >
< div class = "specs" >
< pre translate = "no" > < span class = "attribute" > @spec< / span > locale_from_host(< a href = "https://hexdocs.pm/elixir/String.html#t:t/0" > String.t< / a > (), < a href = "https://hexdocs.pm/elixir/Keyword.html#t:t/0" > Keyword.t< / a > ()) ::
2023-07-24 12:33:21 +03:00
{:ok, < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0" > Cldr.LanguageTag.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 >
2023-07-12 11:28:07 +03:00
< / div >
< p > Returns a " best fit" locale for a host name.< / p > < h2 id = "locale_from_host/2-arguments" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#locale_from_host/2-arguments" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Arguments
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < p > < code class = "inline" > host< / code > is any valid host name< / p > < / li > < li > < p > < code class = "inline" > options< / code > is a keyword list of options. The default
is < code class = "inline" > []< / code > .< / p > < / li > < / ul > < h2 id = "locale_from_host/2-options" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#locale_from_host/2-options" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Options
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < code class = "inline" > :tlds< / code > is a list of territory codes as upper-cased
atoms that are to be considered as top-level domains.
2023-07-24 12:33:21 +03:00
See < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#locale_from_host/2" > < code class = "inline" > Cldr.Locale.locale_from_host/2< / code > < / a > for the default
2023-07-12 11:28:07 +03:00
list.< / li > < / ul > < h2 id = "locale_from_host/2-returns" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#locale_from_host/2-returns" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Returns
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < p > < code class = "inline" > {:ok, langauge_tag}< / code > or< / p > < / li > < li > < p > < code class = "inline" > {:error, {exception, reason}}< / code > < / p > < / li > < / ul > < h2 id = "locale_from_host/2-notes" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#locale_from_host/2-notes" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Notes
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< p > Certain top-level domains have become associated with content
underlated to the territory for who the domain is registered.
Therefore Google (and perhaps others) do not associate these
TLDs as belonging to the territory but rather are considered
generic top-level domain names.< / p > < h2 id = "locale_from_host/2-examples" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#locale_from_host/2-examples" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Examples
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< pre > < code class = "makeup elixir" translate = "no" > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > locale_from_host< / span > < span class = "w" > < / span > < span class = "s" > " a.b.com.au" < / span > < span class = "w" >
2023-08-09 13:47:49 +03:00
< / span > < span class = "nc" > Elixir.Plausible.Cldr< / span > < span class = "o" > .< / span > < span class = "n" > validate_locale< / span > < span class = "p" data-group-id = "3711834097-1" > (< / span > < span class = "ss" > :" en-AU" < / span > < span class = "p" data-group-id = "3711834097-1" > )< / span > < span class = "w" >
2023-07-12 11:28:07 +03:00
2023-08-09 13:47:49 +03:00
< / span > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > locale_from_host< / span > < span class = "p" data-group-id = "3711834097-2" > (< / span > < span class = "s" > " a.b.com.tv" < / span > < span class = "p" data-group-id = "3711834097-2" > )< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "3711834097-3" > {< / span > < span class = "ss" > :error< / span > < span class = "p" > ,< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "3711834097-4" > {< / span > < span class = "nc" > Cldr.UnknownLocaleError< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "s" > " No locale was identified for territory < / span > < span class = "se" > \" < / span > < span class = "s" > tv< / span > < span class = "se" > \" < / span > < span class = "s" > " < / span > < span class = "p" data-group-id = "3711834097-4" > }< / span > < span class = "p" data-group-id = "3711834097-3" > }< / span > < span class = "w" >
2023-07-12 11:28:07 +03:00
2023-08-09 13:47:49 +03:00
< / span > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > locale_from_host< / span > < span class = "p" data-group-id = "3711834097-5" > (< / span > < span class = "s" > " a.b.com" < / span > < span class = "p" data-group-id = "3711834097-5" > )< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "3711834097-6" > {< / span > < span class = "ss" > :error< / span > < span class = "p" > ,< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "3711834097-7" > {< / span > < span class = "nc" > Cldr.UnknownLocaleError< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "s" > " No locale was identified for territory < / span > < span class = "se" > \" < / span > < span class = "s" > com< / span > < span class = "se" > \" < / span > < span class = "s" > " < / span > < span class = "p" data-group-id = "3711834097-7" > }< / span > < span class = "p" data-group-id = "3711834097-6" > }< / span > < / code > < / pre >
2023-07-12 11:28:07 +03:00
< / section >
< / section >
< section class = "detail" id = "new/1" >
< div class = "detail-header" >
< a href = "#new/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" > new(locale_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" >
< / section >
< / section >
< section class = "detail" id = "new!/1" >
< div class = "detail-header" >
< a href = "#new!/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" > new!(locale_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" >
2023-07-24 12:33:21 +03:00
< / section >
< / section >
< section class = "detail" id = "script_direction_from_locale/1" >
< div class = "detail-header" >
< a href = "#script_direction_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" > script_direction_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 >
< span class = "note" > (since 2.37.0)< / span >
< / div >
< section class = "docstring" >
< p > Returns the script direction for a locale.< / p > < h2 id = "script_direction_from_locale/1-arguments" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#script_direction_from_locale/1-arguments" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Arguments
2023-07-24 12:33:21 +03:00
< / a >
< / h2 >
< ul > < li > < code class = "inline" > language_tag< / code > is any language tag 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 >
or any < code class = "inline" > locale_name< / code > 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 = "script_direction_from_locale/1-returns" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#script_direction_from_locale/1-returns" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Returns
2023-07-24 12:33:21 +03:00
< / a >
< / h2 >
< ul > < li > The script direction which is either < code class = "inline" > :ltr< / code > (for left-to-right
scripts) or < code class = "inline" > :rtl< / code > (for right-to-left scripts).< / li > < / ul > < h2 id = "script_direction_from_locale/1-examples" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#script_direction_from_locale/1-examples" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Examples
2023-07-24 12:33:21 +03:00
< / a >
< / h2 >
< pre > < code class = "makeup elixir" translate = "no" > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > script_direction_from_locale< / span > < span class = "w" > < / span > < span class = "s" > " en-US" < / span > < span class = "w" >
< / span > < span class = "ss" > :ltr< / span > < span class = "w" >
< / span > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > script_direction_from_locale< / span > < span class = "w" > < / span > < span class = "ss" > :ar< / span > < span class = "w" >
< / span > < span class = "ss" > :rtl< / span > < / code > < / pre >
2023-07-12 11:28:07 +03:00
< / section >
< / section >
< section class = "detail" id = "territory_from_host/1" >
< div class = "detail-header" >
< a href = "#territory_from_host/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" > territory_from_host(host)< / 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.26.0)< / span >
< / div >
< section class = "docstring" >
< div class = "specs" >
< pre translate = "no" > < span class = "attribute" > @spec< / span > territory_from_host(< a href = "https://hexdocs.pm/elixir/String.html#t:t/0" > String.t< / a > ()) ::
2023-07-24 12:33:21 +03:00
{:ok, < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:territory_code/0" > Cldr.Locale.territory_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 >
2023-07-12 11:28:07 +03:00
< / div >
< p > Returns the last segment of a host that might
be a territory.< / p > < h2 id = "territory_from_host/1-arguments" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#territory_from_host/1-arguments" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Arguments
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < code class = "inline" > host< / code > is any valid host name< / li > < / ul > < h2 id = "territory_from_host/1-returns" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#territory_from_host/1-returns" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Returns
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < p > < code class = "inline" > {:ok, territory}< / code > or< / p > < / li > < li > < p > < code class = "inline" > {:error, {exception, reason}}< / code > < / p > < / li > < / ul > < h2 id = "territory_from_host/1-examples" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#territory_from_host/1-examples" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Examples
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
2023-08-09 13:47:49 +03:00
< pre > < code class = "makeup elixir" translate = "no" > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > territory_from_host< / span > < span class = "p" data-group-id = "1320774693-1" > (< / span > < span class = "s" > " a.b.com.au" < / span > < span class = "p" data-group-id = "1320774693-1" > )< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "1320774693-2" > {< / span > < span class = "ss" > :ok< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "ss" > :AU< / span > < span class = "p" data-group-id = "1320774693-2" > }< / span > < span class = "w" >
2023-07-12 11:28:07 +03:00
2023-08-09 13:47:49 +03:00
< / span > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > territory_from_host< / span > < span class = "p" data-group-id = "1320774693-3" > (< / span > < span class = "s" > " a.b.com" < / span > < span class = "p" data-group-id = "1320774693-3" > )< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "1320774693-4" > {< / span > < span class = "ss" > :error< / span > < span class = "p" > ,< / span > < span class = "w" >
< / span > < span class = "p" data-group-id = "1320774693-5" > {< / span > < span class = "nc" > Cldr.UnknownLocaleError< / span > < span class = "p" > ,< / span > < span class = "w" > < / span > < span class = "s" > " No locale was identified for territory < / span > < span class = "se" > \" < / span > < span class = "s" > com< / span > < span class = "se" > \" < / span > < span class = "s" > " < / span > < span class = "p" data-group-id = "1320774693-5" > }< / span > < span class = "p" data-group-id = "1320774693-4" > }< / span > < / code > < / pre >
2023-07-12 11:28:07 +03:00
< / section >
< / section >
< section class = "detail" id = "territory_from_locale/1" >
< div class = "detail-header" >
< a href = "#territory_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" > territory_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 >
< span class = "note" > (since 2.18.2)< / span >
< / div >
< section class = "docstring" >
< div class = "specs" >
2023-07-24 12:33:21 +03:00
< pre translate = "no" > < span class = "attribute" > @spec< / span > territory_from_locale(< a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0" > Cldr.LanguageTag.t< / a > () | < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0" > Cldr.Locale.locale_name< / a > ()) ::
< a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:territory_code/0" > Cldr.Locale.territory_code< / a > ()< / pre >
2023-07-12 11:28:07 +03:00
< / div >
< p > Returns the territory from a language tag or
locale name.< / p > < h2 id = "territory_from_locale/1-arguments" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#territory_from_locale/1-arguments" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Arguments
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < code class = "inline" > locale< / code > is any language tag returned by
< a href = "#new/1" > < code class = "inline" > Plausible.Cldr.Locale.new/1< / code > < / a >
or a locale name in the list returned by
< a href = "Plausible.Cldr.html#known_locale_names/0" > < code class = "inline" > Plausible.Cldr.known_locale_names/0< / code > < / a > < / li > < / ul > < h2 id = "territory_from_locale/1-returns" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#territory_from_locale/1-returns" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Returns
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > A territory code as an atom< / li > < / ul > < h2 id = "territory_from_locale/1-examples" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#territory_from_locale/1-examples" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Examples
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< pre > < code class = "makeup elixir" translate = "no" > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > territory_from_locale< / span > < span class = "w" > < / span > < span class = "s" > " en-US" < / span > < span class = "w" >
< / span > < span class = "ss" > :US< / span > < span class = "w" >
< / span > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > territory_from_locale< / span > < span class = "w" > < / span > < span class = "s" > " en-US-u-rg-GBzzzz" < / span > < span class = "w" >
< / span > < span class = "ss" > :GB< / span > < / code > < / pre >
< / section >
< / section >
< section class = "detail" id = "timezone_from_locale/1" >
< div class = "detail-header" >
< a href = "#timezone_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" > timezone_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 >
< span class = "note" > (since 2.19.0)< / span >
< / div >
< section class = "docstring" >
< div class = "specs" >
2023-07-24 12:33:21 +03:00
< pre translate = "no" > < span class = "attribute" > @spec< / span > timezone_from_locale(< a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html#t:t/0" > Cldr.LanguageTag.t< / a > () | < a href = "https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#t:locale_name/0" > Cldr.Locale.locale_name< / a > ()) ::
2023-07-12 11:28:07 +03:00
< 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 time zone from a language tag or
locale name.< / p > < h2 id = "timezone_from_locale/1-arguments" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#timezone_from_locale/1-arguments" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Arguments
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < code class = "inline" > locale< / code > is any language tag returned by
< a href = "#new/1" > < code class = "inline" > Plausible.Cldr.Locale.new/1< / code > < / a >
or a locale name in the list returned by
< a href = "Plausible.Cldr.html#known_locale_names/0" > < code class = "inline" > Plausible.Cldr.known_locale_names/0< / code > < / a > < / li > < / ul > < h2 id = "timezone_from_locale/1-returns" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#timezone_from_locale/1-returns" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Returns
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< ul > < li > < p > A time zone ID as a string or< / p > < / li > < li > < p > < code class = "inline" > :error< / code > if no time zone can be determined< / p > < / li > < / ul > < h2 id = "timezone_from_locale/1-examples" class = "section-heading" >
2023-07-25 10:58:48 +03:00
< a href = "#timezone_from_locale/1-examples" >
< i class = "ri-link-m" aria-hidden = "true" > < / i >
Examples
2023-07-12 11:28:07 +03:00
< / a >
< / h2 >
< pre > < code class = "makeup elixir" translate = "no" > < span class = "gp unselectable" > iex> < / span > < span class = "nc" > Plausible.Cldr.Locale< / span > < span class = "o" > .< / span > < span class = "n" > timezone_from_locale< / span > < span class = "w" > < / span > < span class = "s" > " en-US-u-tz-ausyd" < / span > < span class = "w" >
< / span > < span class = "s" > " Australia/Sydney" < / 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
2023-07-25 10:58:48 +03:00
< 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
2023-07-12 11:28:07 +03:00
< 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 >