Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use built-in functions #313

Closed
lynn2910 opened this issue Feb 19, 2023 · 2 comments
Closed

Cannot use built-in functions #313

lynn2910 opened this issue Feb 19, 2023 · 2 comments

Comments

@lynn2910
Copy link

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 ?

@kellpossible
Copy link

Perhaps they were never implemented as per #19 (comment) ?

@alerque
Copy link
Collaborator

alerque commented May 6, 2024

This is definitely a valid issue, built in types were never implemented so of course they could not be used.

That being said I think I'm going to close this issue because we have more specific ones for tracking each implementation. Besides #19, an older duplicate of the general issue, a NUMBER() function is in progress in #353 that can be tracked there. Additionally a specific issue for DATETIME() is at #181.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants