Implement `Localize` for `RelativeTime`

finchie
Aug 16, 2024, 12:17 PM
IRW6JACS3KVVA6HW5SBNBOHOQ2WRBHYGDND3FUWJYKJC7ZMOAVOQC

Dependencies

  • [2] 7U2DXFMP Refactor `fluent_embed::Localize` to support overriding locales
  • [3] BFL2Y7GN Add relative timestamps using `jiff` and `icu_relativetime`

Change contents

  • edit in fluent_embed/src/time.rs at line 1
    [3.53]
    [3.54]
    use crate::Localize;
  • edit in fluent_embed/src/time.rs at line 23
    [3.769][2.2746:2812]()
    const CANONICAL_LOCALE: LanguageIdentifier = DEFAULT_LOCALE;
  • edit in fluent_embed/src/time.rs at line 26
    [3.846]
    [3.954]
    }
  • replacement in fluent_embed/src/time.rs at line 28
    [3.955][2.2813:2852]()
    pub fn localize(&self) -> String {
    [3.955]
    [3.990]
    impl Localize for RelativeTime {
    const CANONICAL_LOCALE: LanguageIdentifier = DEFAULT_LOCALE;
    fn message_for_locale(&self, locale: &LanguageIdentifier) -> String {
  • replacement in fluent_embed/src/time.rs at line 89
    [3.3293][3.3293:3398]()
    // Select which formatter to use
    let locale = DataLocale::from(&Self::CANONICAL_LOCALE);
    [3.3293]
    [3.3398]
    let locale = DataLocale::from(locale);
  • edit in fluent_embed/src/time.rs at line 107
    [3.4358]
    [3.4358]
    fn localize(&self) -> String {
    // TODO: select locale based on environment
    self.message_for_locale(&Self::CANONICAL_LOCALE)
    }