A small Java application using the published Messagevisor Java SDK.
It fetches a production datafile from the Messagevisor Cloudflare Pages example, creates a Messagevisor instance, and evaluates plain and ICU formatted translations.
Learn more at messagevisor.com.
- Java 17 or newer
- Maven 3.9 or newer
- A GitHub account and token with the
read:packagesscope
Messagevisor Java is published through GitHub Packages. GitHub requires authentication when downloading Maven packages, including public packages.
Create ~/.m2/settings.xml with your GitHub username and a personal access token with the read:packages scope:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>YOUR_GITHUB_USERNAME</username>
<password>YOUR_GITHUB_TOKEN</password>
</server>
</servers>
</settings>Create a token at github.com/settings/tokens.
The GitHub Actions workflow uses its repository GITHUB_TOKEN. After creating the messagevisor-example-java repository, grant it read access under the Actions access settings for both published Messagevisor Java packages.
make buildThis compiles the application, runs its unit test, and creates an executable JAR in target/.
make runThe application fetches this datafile by default:
https://messagevisor-example-cloudflare-pages.pages.dev/production/messagevisor-web-en-US.json
You can provide another Messagevisor datafile URL as the first argument:
mvn exec:java -Dexec.args="https://example.com/messagevisor-web-en-US.json"You can also run the packaged application:
java -jar target/messagevisor-example-java-1.0.0.jarThe example uses:
com.messagevisor:messagevisor-sdk:0.2.0com.messagevisor:messagevisor-module-icu:0.2.0
Datafile: https://messagevisor-example-cloudflare-pages.pages.dev/production/messagevisor-web-en-US.json
Locale: en-US
Target: web
Revision: 2
auth.signin: Sign in
nav.home: Home
nav.contact: Contact us before 5:30 PM
The exact localized time output can differ slightly with the CLDR data provided by the installed Java runtime.
The served datafile is authored and deployed by messagevisor-example-cloudflare-pages.