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

Support passed integers #9

Merged
merged 6 commits into from
Sep 25, 2024
Merged

Support passed integers #9

merged 6 commits into from
Sep 25, 2024

Conversation

seddonym
Copy link
Collaborator

@seddonym seddonym commented Sep 24, 2024

Fixes an issue where integers passed as selectors wouldn't get selected correctly. This was because we were calling to_string() on everything before passing it to the message.

To make this simpler to tackle, we stop supporting all objects being passed in as variables, and just support integers and strings for now. (I did attempt floats as well, but it turned into a bit of a rabbit hole, and since we don't seem to use them at the moment, I backed this out.)

@pytest.mark.parametrize(
"number, expected",
(
pytest.param(1, "One", marks=pytest.mark.xfail),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that this fails is the main reason for this PR.

(2, "Something else"),
# Note that for selection to work, the variable must be an integer.
# So "1" is not equivalent to 1.
("1", "Something else"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this behaviour is consistent with Django FTL and Fluent Playground.

@seddonym seddonym force-pushed the support-passed-objects branch 2 times, most recently from 99e8288 to e71fb7d Compare September 24, 2024 16:01
Only certain values can be passed, see
https://docs.rs/fluent/latest/fluent/enum.FluentValue.html.

But we narrow down even further for the time being.
Pointed out by cargo clippy
@seddonym seddonym marked this pull request as ready for review September 24, 2024 16:04
@seddonym seddonym requested a review from a team as a code owner September 24, 2024 16:04
@seddonym seddonym changed the title Support passed objects Support passed integers Sep 24, 2024
@seddonym seddonym merged commit e0142fe into main Sep 25, 2024
1 check passed
@seddonym seddonym deleted the support-passed-objects branch September 25, 2024 07:59
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.

2 participants