Skip to content

Commit 9c4f80a

Browse files
committed
feat(bundle): Add external access to file loader
1 parent 52633a6 commit 9c4f80a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fluent/init.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ function FluentBundle:add_messages (input, locale)
6464
return resource + messages
6565
end
6666

67+
function FluentBundle:load_file (fname, locale)
68+
locale = locale or self:get_locale()
69+
local syntax = FluentSyntax()
70+
local messages =
71+
type(fname) == "string"
72+
and syntax:parsefile(fname)
73+
or tablex.reduce('+', tablex.imap(function (v)
74+
return syntax:parsefile(v)
75+
end, fname))
76+
local resource = self:get_resource(locale)
77+
return resource + messages
78+
end
79+
6780
function FluentBundle:format (identifier, parameters)
6881
local resource = self:get_resource()
6982
local message = resource:get_message(identifier)

0 commit comments

Comments
 (0)