Skip to content

Cannot use built-in functions #313

Description

@lynn2910

Hello, i have this fluent content:

server_info_desc =   > 🏷️ **Quelques statistiques :**
  {"** **"}
  `{ NUMBER($emojis) }` emojis
  `{ NUMBER($stickers) }` stickers
  `{ NUMBER($threads) }` threads
  `{ NUMBER($categories) }` categories

But, when i run it, the text displayed is:

⁨{NUMBER()}⁩ emojis
⁨{NUMBER()}⁩ stickers
⁨{NUMBER()}⁩ threads
⁨{NUMBER()}⁩ categories

So, at first, I was thinking that i wasn't using the good names or syntax, but everything work properly on web playground, and, this is how I'm declaring all arguments:

            let mut fluent_args = FluentArgs::new();
            {
                fluent_args.set("emojis", emojis_nb);
                fluent_args.set("stickers", stickers_nb);
                fluent_args.set("threads", threads);
                fluent_args.set("categories", categories);
            }

Because of all that, the only option is that I missed something when formatting the message.
I use this function:

  pub fn get(&self, lang: &String, id: &str, args: Option<&FluentArgs<'_>>) -> String {
    if let Some(bundle) = self.lib.get(lang) {
      let msg = bundle.get_message(id);
      if let Some(m) = msg {
        if let Some(value) = m.value() {
          let mut err = vec![];
          bundle.format_pattern(value, args, &mut err).to_string()
        } else {
          NO_VALUE.clone().to_string()
        }
      } else {
        NO_MESSAGE.clone().to_string()
      }
    } else {
      NO_LANG.clone().to_string()
    }
  }

Anyone know why this isn't working properly ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions