Skip to content

Commit e573b64

Browse files
authored
Merge pull request #3 from QuickWrite/develop
Create the first working version of fluent `0.1-alpha`.
2 parents 222e233 + 6163b49 commit e573b64

File tree

87 files changed

+5376
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+5376
-32
lines changed

.github/workflows/code_quality.yml

-27
This file was deleted.

.gitignore

+96-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
111
# Compiled class file
212
*.class
313

@@ -7,9 +17,6 @@
717
# BlueJ files
818
*.ctxt
919

10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
1320
# Package Files #
1421
*.jar
1522
*.war
@@ -19,6 +26,91 @@
1926
*.tar.gz
2027
*.rar
2128

29+
# Mobile Tools for Java (J2ME)
30+
.mtj.tmp/
31+
2232
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2333
hs_err_pid*
24-
replay_pid*
34+
35+
*~
36+
37+
# temporary files which can be created if a process still has a handle open of a deleted file
38+
.fuse_hidden*
39+
40+
# KDE directory preferences
41+
.directory
42+
43+
# Linux trash folder which might appear on any partition or disk
44+
.Trash-*
45+
46+
# .nfs files are created when an open file is removed but is still being accessed
47+
.nfs*
48+
49+
# General
50+
.DS_Store
51+
.AppleDouble
52+
.LSOverride
53+
54+
# Icon must end with two \r
55+
Icon
56+
57+
# Thumbnails
58+
._*
59+
60+
# Files that might appear in the root of a volume
61+
.DocumentRevisions-V100
62+
.fseventsd
63+
.Spotlight-V100
64+
.TemporaryItems
65+
.Trashes
66+
.VolumeIcon.icns
67+
.com.apple.timemachine.donotpresent
68+
69+
# Directories potentially created on remote AFP share
70+
.AppleDB
71+
.AppleDesktop
72+
Network Trash Folder
73+
Temporary Items
74+
.apdisk
75+
76+
# Windows thumbnail cache files
77+
Thumbs.db
78+
Thumbs.db:encryptable
79+
ehthumbs.db
80+
ehthumbs_vista.db
81+
82+
# Dump file
83+
*.stackdump
84+
85+
# Folder config file
86+
[Dd]esktop.ini
87+
88+
# Recycle Bin used on file shares
89+
$RECYCLE.BIN/
90+
91+
# Windows Installer files
92+
*.cab
93+
*.msi
94+
*.msix
95+
*.msm
96+
*.msp
97+
98+
# Windows shortcuts
99+
*.lnk
100+
101+
target/
102+
103+
pom.xml.tag
104+
pom.xml.releaseBackup
105+
pom.xml.versionsBackup
106+
pom.xml.next
107+
108+
release.properties
109+
dependency-reduced-pom.xml
110+
buildNumber.properties
111+
.mvn/timing.properties
112+
.mvn/wrapper/maven-wrapper.jar
113+
.flattened-pom.xml
114+
115+
# Common working directory
116+
run/

README.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
11
# 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).

pom.xml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>net.quickwrite</groupId>
8+
<artifactId>fluent4j</artifactId>
9+
<version>0.1.0-alpha</version>
10+
<build>
11+
<plugins>
12+
<plugin>
13+
<groupId>org.apache.maven.plugins</groupId>
14+
<artifactId>maven-compiler-plugin</artifactId>
15+
<version>3.10.1</version>
16+
17+
<configuration>
18+
<source>15</source>
19+
<target>15</target>
20+
</configuration>
21+
</plugin>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-javadoc-plugin</artifactId>
25+
<version>3.4.1</version>
26+
<configuration>
27+
<doclint>none</doclint>
28+
</configuration>
29+
</plugin>
30+
</plugins>
31+
</build>
32+
33+
<properties>
34+
<maven.compiler.source>16</maven.compiler.source>
35+
<maven.compiler.target>16</maven.compiler.target>
36+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
38+
</properties>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>com.ibm.icu</groupId>
43+
<artifactId>icu4j</artifactId>
44+
<version>68.1</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>org.apache.commons</groupId>
49+
<artifactId>commons-text</artifactId>
50+
<version>1.9</version>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>junit</groupId>
55+
<artifactId>junit</artifactId>
56+
<version>4.13.1</version>
57+
<scope>test</scope>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>org.junit.jupiter</groupId>
62+
<artifactId>junit-jupiter-params</artifactId>
63+
<version>5.8.1</version>
64+
<scope>test</scope>
65+
</dependency>
66+
67+
<dependency>
68+
<groupId>org.junit.jupiter</groupId>
69+
<artifactId>junit-jupiter-engine</artifactId>
70+
<scope>test</scope>
71+
<version>5.8.2</version>
72+
</dependency>
73+
</dependencies>
74+
75+
</project>

qodana.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version: "1.0"
2+
linter: jetbrains/qodana-jvm-community:2022.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package net.quickwrite.fluent4j.ast;
2+
3+
import net.quickwrite.fluent4j.util.StringSlice;
4+
5+
6+
/**
7+
* A FluentAttribute defines a subpart of a FluentMessage that holds more
8+
* context data.<br>
9+
*
10+
* <pre>
11+
* login-input = Predefined value
12+
* .placeholder = [email protected]
13+
* .aria-label = Login input value
14+
* .title = Type your login email
15+
* </pre>
16+
* <p>
17+
* In this example the {@code login-input} has three different attributes:
18+
* A {@code placeholder} attribute, {@code aria-label} attribute, and a {@code title} attribute.
19+
*/
20+
public class FluentAttribute extends FluentBase {
21+
/**
22+
* Creates a new FluentAttribute with the identifier and the content.
23+
* <br>
24+
* The content gets parsed into a list of TextElements and Placeables
25+
* that can be queried later.
26+
*
27+
* @param identifier The information that uniquely represents the Attribute.
28+
* @param content The content that needs to be parsed.
29+
*/
30+
public FluentAttribute(final StringSlice identifier, final StringSlice content, final int whitespace) {
31+
super(identifier, content, whitespace);
32+
}
33+
34+
/**
35+
* Returns a serialized version of the object.
36+
*
37+
* @return The object in string form.
38+
*/
39+
@Override
40+
public String toString() {
41+
return "FluentAttribute: {\n" +
42+
"\t\t\tidentifier: \"" + this.identifier + "\"\n" +
43+
"\t\t\tfluentElements: " + this.fluentElements + "\n" +
44+
"\t\t}";
45+
}
46+
}

0 commit comments

Comments
 (0)