#[non_exhaustive]pub struct Locale {Show 15 fields
pub tag: String,
pub decimal_mark: String,
pub big_mark: String,
pub min_grouping_digits: usize,
pub currency_symbol: String,
pub currency_position: CurrencyPosition,
pub currency_spacing: String,
pub percent_suffix: String,
pub months_short: [String; 12],
pub months_long: [String; 12],
pub days_short: [String; 7],
pub days_long: [String; 7],
pub date_format: String,
pub month_format: String,
pub time_format: String,
}Expand description
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tag: StringCanonical BCP-47 tag of the preset, e.g. "de-DE".
decimal_mark: StringDecimal mark ("." / ",").
big_mark: StringThousands separator (",", ".", " ", "'"; "" disables grouping).
min_grouping_digits: usizeGroup thousands only when the integer part has at least
3 + min_grouping_digits digits (CLDR’s minimum grouping digits).
1 (every preset) groups 1000 as 1.000; 2 leaves 2020 alone
and groups from 10.000.
currency_symbol: StringThe locale’s currency symbol ("$", "€", "£").
currency_position: CurrencyPositionWhere the currency symbol goes.
currency_spacing: StringText between amount and currency symbol ("" or " ").
percent_suffix: StringSuffix of percentages ("%" in English, " %" in German / French).
months_short: [String; 12]Abbreviated month names, January first (%b).
months_long: [String; 12]Full month names, January first (%B).
days_short: [String; 7]Abbreviated weekday names, Sunday first (%a).
days_long: [String; 7]Full weekday names, Sunday first (%A).
date_format: Stringstrftime format of a calendar date (default date-axis labels at day
resolution), e.g. "%-d. %b %Y" → 15. Okt. 2026.
month_format: Stringstrftime format of a month (default monthly date-axis labels), e.g.
"%b %Y" → Okt. 2026.
time_format: Stringstrftime format of a time of day, appended to the date for datetimes
that are not at midnight, e.g. "%H:%M".
Implementations§
Source§impl Locale
impl Locale
Sourcepub fn fr_fr() -> Self
pub fn fr_fr() -> Self
French (France): 1 234,5, 1 234,50 €, 50 %, 15 oct. 2026.
The thousands mark is a plain space (CLDR uses a narrow no-break space,
which many fonts lack); set big_mark to override.
Sourcepub fn try_from_tag(tag: &str) -> Option<Self>
pub fn try_from_tag(tag: &str) -> Option<Self>
Sourcepub fn from_tag(tag: &str) -> Self
pub fn from_tag(tag: &str) -> Self
Like try_from_tag, falling back to
en_us for unknown tags.
use ggplot_rs::locale::Locale;
assert_eq!(Locale::from_tag("de-DE").tag, "de-DE");
assert_eq!(Locale::from_tag("fr_FR.UTF-8").tag, "fr-FR");
assert_eq!(Locale::from_tag("en-GB").tag, "en-GB");
assert_eq!(Locale::from_tag("xx-YY").tag, "en-US");Sourcepub fn with_decimal_mark(self, mark: &str) -> Self
pub fn with_decimal_mark(self, mark: &str) -> Self
Replace the decimal mark.
Sourcepub fn with_big_mark(self, mark: &str) -> Self
pub fn with_big_mark(self, mark: &str) -> Self
Replace the thousands mark ("" disables grouping).
Sourcepub fn with_min_grouping_digits(self, digits: usize) -> Self
pub fn with_min_grouping_digits(self, digits: usize) -> Self
Replace the minimum grouping digits (see
min_grouping_digits).
Sourcepub fn with_currency(self, symbol: &str) -> Self
pub fn with_currency(self, symbol: &str) -> Self
Use another currency symbol, placed by this locale’s convention:
Locale::de_de().with_currency("CHF") formats 1.234,50 CHF.
Sourcepub fn currency_affixes(&self, symbol: &str) -> (String, String)
pub fn currency_affixes(&self, symbol: &str) -> (String, String)
(prefix, suffix) that place symbol by this locale’s convention:
("$", "") for en-US, ("", " €") for de-DE.
Sourcepub fn localize_number(&self, s: &str) -> String
pub fn localize_number(&self, s: &str) -> String
Re-render a number formatted the default way (. decimal mark, , or
no thousands grouping, optional leading -) with this locale’s marks:
"-1234.5" / "-1,234.5" → "-1.234,5" in de-DE. Anything that is not
such a number (NaN, inf, text) is returned unchanged.
Sourcepub fn parse_number(&self, s: &str) -> Option<f64>
pub fn parse_number(&self, s: &str) -> Option<f64>
Inverse of localize_number for parsing a
label back to a number: strips thousands marks and restores ..
Sourcepub fn format_number(&self, v: f64) -> String
pub fn format_number(&self, v: f64) -> String
Format a break value like the default axis labels (integers verbatim,
otherwise up to two decimals, trailing zeros trimmed) with this
locale’s marks: 1234.5 → "1.234,5" in de-DE.
Sourcepub fn strftime(&self, epoch_secs: i64, fmt: &str) -> String
pub fn strftime(&self, epoch_secs: i64, fmt: &str) -> String
Format epoch seconds (UTC) with a strftime-style format, using this
locale’s month and weekday names. Supported: %Y %y %m %-m %b %B %d %-d %e %a %A %H %M %S %%.
Sourcepub fn format_datetime(&self, epoch_secs: i64) -> String
pub fn format_datetime(&self, epoch_secs: i64) -> String
Format epoch seconds (UTC) as this locale’s date (date_format),
plus time_format when not at midnight.
Trait Implementations§
impl StructuralPartialEq for Locale
Auto Trait Implementations§
impl Freeze for Locale
impl RefUnwindSafe for Locale
impl Send for Locale
impl Sync for Locale
impl Unpin for Locale
impl UnsafeUnpin for Locale
impl UnwindSafe for Locale
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more