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

V0.7.0 #41

Merged
merged 2 commits into from
Nov 19, 2023
Merged

V0.7.0 #41

merged 2 commits into from
Nov 19, 2023

Conversation

Ygg01
Copy link
Owner

@Ygg01 Ygg01 commented Nov 19, 2023

version 0.7.0

  • Experimental features when UseExperimental flag is true:
    • Dynamic Reference - ability to reference terms/message using $$term_ref.
      After defining it in file like so:

      # example.ftl
      cat = {$number ->
          *[one] Cat
          [other] Cats
      }
      dog = {$number ->
          *[one] Dog
          [other] Dogs
      }
      attack-log = { $$attacker(number: $atk_num) } attacked {$$defender(number: $def_num)}.

      It can be called like following:

      var args = new Dictionary<string, IFluentType>
      {
          ["attacker"] = (FluentReference)"cat",
          ["defender"] = (FluentReference)"dog",
      };
      Assert.True(bundle.TryGetMessage("attack-log", args, out _, out var message));
      Assert.AreEqual("Cat attacked Dog.", message);
    • Dynamic Reference attributes - You can call an attribute of a dynamic reference. It will be resolved at runtime, so
      make sure your term/message has the associated attribute.
      Example:

      # dyn_attr.ftl
      -creature-elf = elf
        .StartsWith = vowel
      
      you-see = You see { $$object.StartsWith ->
        [vowel] an { $$object }
        *[consonant] a { $$object }
      }.
      var args = new Dictionary<string, IFluentType>
      {
        ["object"] = (FluentReference)"creature-elf",
      };
      Assert.True(bundle.TryGetMessage("you-see", args, out _, out var message));
      Assert.AreEqual("You see an elf.", message);
    • Term passing - experimental feature allows users to override term arguments.

      -ship = Ship
          .gender =  { $style ->
              *[traditional] neuter
              [chicago] feminine
          }
      ship-gender = { -ship.gender(style: $style) ->
          *[masculine] He
          [feminine] She
          [neuter] It
      }

      Usually when style isn't passed, it would to default -ship.gender() i.e. neuter, which would set ship-gender selector to neuter i.e. It.
      In above example if we set style variable to chicago, -ship.gender() it would evaluate feminine, so ship-gender would would evaluate to She.

Copy link

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@Ygg01 Ygg01 merged commit 824c7f1 into master Nov 19, 2023
5 checks passed
@Ygg01 Ygg01 deleted the v0.7.0 branch November 19, 2023 01:39
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

Successfully merging this pull request may close these issues.

1 participant