File tree 1 file changed +31
-1
lines changed
1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 1
1
# fluent4j
2
- A Java library that implements Mozilla Fluent
2
+ A Java library that implements [ Mozillas Fluent project] ( https://www.projectfluent.org/ ) .
3
+
4
+ ## Usage
5
+
6
+ You could either use the library directly without all of the abstraction and create all of the
7
+ objects by yourself:
8
+
9
+ ``` java
10
+ FluentResource resource = FluentParser . parse(" emails = You have { $unreadEmails } unread emails." );
11
+ FluentBundle bundle = new ResourceFluentBundle (ULocale . ENGLISH , resource);
12
+
13
+ FluentArgs arguments = new ResourceFluentArguments ();
14
+ arguments. setNamed(" unreadEmails" , new NumberLiteral (10 ));
15
+
16
+ System . out. println(bundle. getMessage(" emails" , arguments));
17
+ ```
18
+
19
+ or you could use the builders that the library provides for this:
20
+
21
+ ``` java
22
+ FluentBundle bundle = new FluentBundleBuilder (ULocale . ENGLISH , " emails = You have { $unreadEmails } unread emails." )
23
+ .build();
24
+ FluentArgs arguments = new FluentArgsBuilder (). setNamed(" unreadEmails" , 10 ). build();
25
+
26
+ System . out. println(bundle. getMessage(" emails" , arguments));
27
+ ```
28
+
29
+ In both cases they would print the message ` You have 10 unread emails. ` .
30
+
31
+ ## License
32
+ This project is licensed under the permissive [ Apache 2.0 license] ( LICENSE ) .
You can’t perform that action at this time.
0 commit comments