Conversation
This will be incorporated to utilities s.t. we can directly pass strings instead of manually parsing at call-sites.
This optionally moves the parsing to the utility bodies, which allows us to simplify tests and eventually call-sites.
|
The diffstat is rather large for my taste, but it's mostly tests. I have attempted to follow the existing project conventions, if there's something that I missed that needs adjusting, just let me know. Also if I misinterpreted any terminology around Fluent strings I'd be happy to be corrected -- this was the first time for me fiddling with the format as well as with its AST. |
|
|
||
| def _entry_messages(entry: Entry[Message]) -> Iterator[Message]: | ||
| """Iterate over the entry's value message and its property messages.""" | ||
| if isinstance(entry.value, (PatternMessage, SelectMessage)): |
There was a problem hiding this comment.
Message is a union (not a class), so mypy was complaining. A more future-proof approach would be to place this check behind a TypeIs guard; let me know if you want that or not.
eemeli
left a comment
There was a problem hiding this comment.
Took a quick peek at this before I head off to PTO, so please dismiss my review if it gets stale:
As @mathjazz mentions in #2363 (comment), this API should be fetching all available terms in a project+locale, not just the ones referenced in a single entity. Terms are Fluent-only, and identifiable by their identifier starting with a hyphen-minus - character.
There also should be no need to do any parsing as a part of the work here.
|
Thanks for the quick check before the PTO @eemeli! I definitely misread the intent in #2363 (comment), but I now see the assumption and the trade-off makes sense. re.
I'm not super familiar with the data model, so correct me if I'm wrong, but as I see now |
Yes. For Fluent terms, you'll also need to account for |
Refs. #2363
In this changeset we introduce the
/get-fluent-reference-variants/endpointthat allows consumers to retrieve any selectors and their variants as referenced
by a Fluent entity for a locale.
This endpoint requires an
entitypk and alocalecode.The view:
referenced by it are collected.
Should there be multiple entities defining the same key (rare, but technically
possible), the entity's own resource takes precedence.
extracted.
Fluent string parsing, message/term reference and selector variants extraction
has been implemented as free functions under
fluent_utils.py, with unit tests.These are directly leveraged by the XHR view that implements the business logic.
All code paths here contain integration tests.
Note this is the building block for the Fluent variants autocomplete feature
that will be implemented separately, so the endpoint is not being used yet.