Skip to content

Commit 4a35311

Browse files
committed
Update README with 0.0.3 status and updated demo
1 parent 8e2cbac commit 4a35311

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Other implementations already exist in [Rust][fluent-rs], [Javascript][fluent.js
1717

1818
As of now it is possible to use this for simple string localization (without parameter substitution) but it is not feature complete nor is the API stable (see [lua alternatives](#alternatives). If you have ideas about how the Lua API should work or wish to contribute, please join the project chat and/or open [issues](https://github.com/alerque/fluent-lua/issues) for points of discussion.
1919

20+
### 0.0.3
21+
22+
Added support for more types including format support for TextElement, StringLiteral, NumberLiteral, and VariableReference. Variable sutstitions can be done by passing a parameters table to `format()`. Internally manipulating nodes in the API is now easier with meta methods. For example merge comments with `Comment + Comment`, attach childred with `Message * Comment`, etc.
23+
2024
### 0.0.2
2125

2226
Massaged the AST returned by the PEG grammar so that about 1/3 of the possible types look like the reference Fluent spec. A basic Lua API is starting to take shape, modeled most closely to the Python implementation. It is possible to load and parse almost any FTL file, and possible to format any messages that are plain strings (no parameters, attributes, functions, or other jazz yet). Note there is no locale handling yet so it's only usable with separate instances per locale. Also `add_messages()` likely only works once, so cram your whole FTL resource in there for now.
@@ -31,14 +35,24 @@ Initialized project with some boiler plate Lua aparatus.
3135

3236
## Usage
3337

38+
Lua code `demo.lua`:
39+
3440
```lua
3541
local FluentBundle = require("fluent")
36-
3742
local en = FluentBundle("en-US")
43+
en:add_messages({
44+
"foo = bar",
45+
"hello = Hello { $name }!"
46+
})
47+
print(en:format("foo"))
48+
print(en:format("hello", { name = "World" }))
49+
```
3850

39-
en:add_messages("foo = bar")
51+
Output of `lua demo.lua`:
4052

41-
en:format("foo")
53+
```txt
54+
bar
55+
Hello World!
4256
```
4357

4458
## Alternative(s)

0 commit comments

Comments
 (0)