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

Default variant is not being transpiled properly #3

Open
germanftorres opened this issue Nov 12, 2019 · 2 comments
Open

Default variant is not being transpiled properly #3

germanftorres opened this issue Nov 12, 2019 · 2 comments

Comments

@germanftorres
Copy link

Hi,

I'm trying to use this compiler in my build process. With the demo ftl source in README.md, when trying to display the sync-dialog-title (which references another key), I get an exception ($.capitalization, can't access property capitalization of undefined). Seeing the generated ouput I feel that maybe in sync-dialog-title the call to value() should be value({}) so that the call does not throw, but not really sure.

Anyway great work, I would guess that messageformat is a more established tool, but fluent also looks promising as long as we can rely on build time tools like this one.

Thanks!

Germán

output:

import Runtime from "fluent-compiler/runtime"
const { bundle, isol, select } = Runtime("es")
const R = new Map([

["-sync-brand-name", { value: $ => [select($.capitalization, "uppercase", { uppercase: "Account Firefox", lowercase: "account Firefox" })] }],
["sync-dialog-title", { value: $ => [R.get("-sync-brand-name").value()] }],
["sync-headline-title", { value: $ => [isol(R.get("-sync-brand-name").value()), ": il modo migliore\nper avere i tuoi dati sempre con te"] }],
// Explicitly request the lowercase variant of the brand name.
["sync-signedout-account-title", { value: $ => ["Connetti il tuo ", isol(R.get("-sync-brand-name").value({ capitalization: "lowercase" }))] }],
["welcome", { value: $ => ["Hi how are you!!"] }],

])
export const resource = R
export default bundle(R)

input

-sync-brand-name = {$capitalization ->
   *[uppercase] Account Firefox
    [lowercase] account Firefox
}

sync-dialog-title = {-sync-brand-name}
sync-headline-title =
    {-sync-brand-name}: il modo migliore
    per avere i tuoi dati sempre con te

# Explicitly request the lowercase variant of the brand name.
sync-signedout-account-title =
    Connetti il tuo {-sync-brand-name(capitalization: "lowercase")}

welcome = 
    Hi how are you!!
@erickwilder
Copy link

@germanftorres

Just calling.value({}) doesn't seem to really solve the issue here apart of silencing the error. How one could pass the correct capitalization value (uppercase/lowercase in this example) if the value used is always an empty object?

I'll dig a bit more into the compiler code to see if I can shed some light in this issue as well understand more how the compiled code with selectors is supposed to be used/generated.

@erickwilder
Copy link

@eemeli
Is this related to this comment on one of the tests for select expressions?

https://github.com/eemeli/fluent-compiler/blob/master/test/select_expressions.test.js#L27

I'm trying to figure it out how to avoid the undefined reference without breaking any API

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

No branches or pull requests

2 participants