Skip to content

Allow accessing nested VariantLists #187

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

Closed
stasm opened this issue Oct 19, 2018 · 4 comments
Closed

Allow accessing nested VariantLists #187

stasm opened this issue Oct 19, 2018 · 4 comments
Labels

Comments

@stasm
Copy link
Contributor

stasm commented Oct 19, 2018

There is currently no way to access variants nested in other variants:

-brand-name = {
    *[singular] {
        *[nominative] Thing
        [genitive] Thing's
    }
    [plural] {
        *[nominative] Things
        [genitive] Things'
    }
}
# Nested VariantExpressions (currently syntax errors)
A = {-brand-name[singular][genitive]}
B = {-brand-name[singular, genitive]}

If #176 is accepted and if parameterized terms replace variant lists, we might not need this at all. Otherwise, I would suggest to use the same syntax as will be used for list selectors (#4). My comment in #4 (comment) has the rationale for my preference for option B.

@stasm
Copy link
Contributor Author

stasm commented Oct 19, 2018

For both A and B we should find an answer to the question no. 6 from #176 (comment). Should be it possible to invoke the default value of an upper level and pass a specific key to the nested VariantList? In pseudocode:

# Either a new Fluent symbol NONE,
# or just leverage the fact that no variant has key == NONE.
X = {-brand-name[NONE, genitive]}
# Empty placeable could mean "null"
X = {-brand-name[{}, genitive]}
# Implicit "null"
X = {-brand-name[, genitive]}

I don't like any of these solutions. I think we should encourage explicit syntax, especially in areas which are already quite complex. Terms with variant lists definitely qualify as such in my book. I'm OK with answering No to the original question, and requiring all keys to be always present:

B = {-brand-name[singular, genitive]}

@stasm
Copy link
Contributor Author

stasm commented Nov 6, 2018

Parameterized terms (#176) supersede variant lists, making this issue obsolete. I filed #204 to remove variant lists from the syntax.

@stasm stasm closed this as completed Nov 6, 2018
@mariusrak
Copy link

Hi, can you please explain how can I use parametrized terms to achieve what variant lists would allow? Thanks.

@artlung
Copy link

artlung commented Aug 28, 2024

@mariusrak I suspect this is not a great place to ask a question like that. But I suspect looking at https://projectfluent.org/fluent/guide/selectors.html will get you started at how to create ftl with variants. Also if I had a question I might feel inclined to ask on StackOverflow with a project-fluent tag. https://stackoverflow.com/questions/tagged/project-fluent

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

No branches or pull requests

3 participants