Repository navigation
|
In the Hledger project we have phrases I want to have a message I tried to achieve that with selections I tried to solve the problem with attributes |
Replies: 2 comments
|
You are close, but the missing piece is that Fluent does not give you a dynamic “return this other message/term and call it” reference. In your first example, the variants of The usual Fluent shape is to put the reusable grammar in a term, parameterize that term, and then call it from each report title. The Fluent guide explicitly supports term parameters, and it also describes term attributes as private grammatical metadata that can be used as selectors. For example: -period-label =
{ $period ->
[yearly] { $gender ->
[feminine] Jährliche
[masculine] Jährlicher
*[other] Jährlich
}
[quarterly] { $gender ->
[feminine] Vierteljährliche
[masculine] Vierteljährlicher
*[other] Vierteljährlich
}
[monthly] { $gender ->
[feminine] Monatliche
[masculine] Monatlicher
*[other] Monatlich
}
*[other] { "" }
}
-balance-report = Saldenbericht
.gender = masculine
-income-statement = Einkommenüberschussrechnung
.gender = feminine
balance-report = { -period-label(period: $period, gender: -balance-report.gender) } { -balance-report }
income-statement = { -period-label(period: $period, gender: -income-statement.gender) } { -income-statement }That still leaves you with one public message per report type, but it keeps the period inflection table in one place and keeps the report gender next to the report term. If the application really wants to call one If this matches the constraint you hit, please mark it as answered so the “term parameters yes, dynamic term references no” distinction is easier to find. |
|
I think your proposed solution works in principle. Unfortunately, currently the Haskell implementation |
You are close, but the missing piece is that Fluent does not give you a dynamic “return this other message/term and call it” reference.
In your first example, the variants of
-get-periodare just text values likeperiod-yearly; they are not evaluated as a second reference to theperiod-yearlymessage. In the second example, the same issue shows up as-get-period.masculine: the attribute has to be on a concrete term, not on the result of a dynamic lookup.The usual Fluent shape is to put the reusable grammar in a term, parameterize that term, and then call it from each report title. The Fluent guide explicitly supports term parameters, and it also describes term attributes as private gramm…