File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -172,8 +172,8 @@ node_types.Placeable = class({
172172 self .expression = node_to_type (node .expression [1 ])
173173 end
174174 end ,
175- format = function (self )
176- return self .expression . value
175+ format = function (self , parameters )
176+ return self .expression : format ( parameters )
177177 end
178178 })
179179
@@ -206,6 +206,16 @@ node_types.NumberLiteral = class({
206206 })
207207
208208node_types .VariableReference = class ({
209+ _base = FluentNode ,
210+ _init = function (self , node )
211+ self :super (node )
212+ end ,
213+ format = function (self , parameters )
214+ return parameters [self .id .name ]
215+ end
216+ })
217+
218+ node_types .MessageReference = class ({
209219 _base = FluentNode ,
210220 _init = function (self , node )
211221 self :super (node )
Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ describe('fluent.bundle', function ()
3434 assert .same (" bar baz quz -3.14" , en :format (" foo" ))
3535 end )
3636
37+ it (' should parse and format a variable substitution' , function ()
38+ local en = FluentBundle (" en-US" )
39+ en :add_messages (' foo = bar { $baz }' )
40+ assert .same (" bar qux" , en :format (" foo" , { baz = " qux" }))
41+ end )
42+
3743 it (' should keep locale instances separate' , function ()
3844 local en = FluentBundle (" en-US" )
3945 local tr = FluentBundle (" tr-TR" )
You can’t perform that action at this time.
0 commit comments