Skip to content

Conversation

seddonym
Copy link
Collaborator

@seddonym seddonym commented Sep 20, 2024

Tweaks to improve the local dev experience, in particular around running tests and documentation.

I've also taken the opportunity to slightly change the function parameters.

image

Prior to this commit, the tests and the debugger were awkward to run
from Pycharm, due to how it added certain directories to the Python path
automatically, and how it interacted with compiled Python extensions.

This moves the tests up one level into a tests directory, which should
simplify the developer experience and everything will just work.
It's useful to be able to run maturin develop when working in a mixed
Python/Rust environment.
@seddonym seddonym force-pushed the dev-ergonomics branch 5 times, most recently from d86417c to 53202e7 Compare September 20, 2024 16:09
Prior to this, changes to the Rust code wouldn't get picked up when
running the Python tests.
Although this is slightly more verbose, it gives us better opportunities
for backward-compatibility if we choose to add new options to
`get_translation` later. The name 'variables' is taken from the official
Fluent docs https://projectfluent.org/fluent/guide/variables.html
@seddonym seddonym marked this pull request as ready for review September 23, 2024 08:16
@seddonym seddonym requested a review from a team as a code owner September 23, 2024 08:16
@seddonym seddonym requested a review from dooferlad September 23, 2024 08:17
Copy link
Contributor

@dooferlad dooferlad left a comment

Choose a reason for hiding this comment

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

One niggle about a naming inconsistency with the upstream package. Other than that, all looks good to me!

fn new(namespace: &str, ftl_filenames: &'_ Bound<'_, PyList>) -> PyResult<Self> {
let langid_en: LanguageIdentifier = namespace.parse().expect("Parsing failed");
let mut bundle = FluentBundle::new_concurrent(vec![langid_en]);
fn new(language: &str, ftl_filenames: &'_ Bound<'_, PyList>) -> PyResult<Self> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be locale (at least, that is what the docs use: https://docs.rs/fluent/latest/fluent/bundle/struct.FluentBundle.html#method.new).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm... it's a bit confusing.

The reason I called it language here is because I think we are expecting it to be a Unicode Language Identifier rather than a locale, but I do take your point that it isn't consistent with the function name. But have I got it wrong there? It feels weird to me to call it locale if it is meant to be a language identfier, if that is actually the case.

Merging for now but happy to continue to iterate...

@seddonym seddonym merged commit 3dc1946 into main Sep 23, 2024
1 check passed
@seddonym seddonym deleted the dev-ergonomics branch September 23, 2024 13:42
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