Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Pante/Lingua-Franca

Repository files navigation

Travis-CI Funding Maintainability Coverage Stable Branch releases-maven snapshots-maven javadoc Discord

Lingua Franca is an annotation-driven internationalisation library that features semi-automated locale file(s) generation. In addition, the library supports properties, JSON and YAML files.

The master branch contains the bleeding edge, unreleased version of the project. Please view the stable branch for the latest stable release. For more information, please see the example project and wiki.


Feature Comparison:

Plain Java Lingua Franca
Annotations
Formatted Messages
Optional Messages
Embedded Resources
Runtime Resources
Locale File Generation
Locale File (properties)
Locale File (JSON)
Locale File (YAML)

Lingua Franca 1.0.2 and above requires Java 11; prior versions require Java 10.

Java 11+ Maven Artifact:

<!-- Release Builds -->
<repository>
  <id>lingua-releases</id>
  <url>https://repo.karuslabs.com/repository/lingua-franca-releases/</url>
</repository>

<!-- Nightly Builds -->
<repository>
  <id>lingua-snapshots</id>
  <url>https://repo.karuslabs.com/repository/lingua-franca-nightly/</url>
</repository>

<dependencies>
  <dependency>
      <groupId>com.karuslabs</groupId>
      <artifactId>lingua-franca</artifactId>
      <version>1.0.7</version>
  </dependency>
</dependencies>

<build>
    <!-- Optional but highly recommended -->
    <plugin>
        <groupId>com.karuslabs</groupId>
        <artifactId>lingua-maven-plugin</artifactId>
        <version>1.0.7</version>
        <executions>
            <execution>
                <goals>
                    <!-- Lints the usage of Lingua Franca annotations in the project -->
                    <goal>lint</goal>
                    <!-- Generates the embedded template locale file(s) at compilation -->
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</build>

Getting Started

@Namespace("messages")
@ClassLoaderSources({"translations"})
class Foo {
    
    Bundler bundler = Bundler.bundler();
	
    void register() {
        bundler.loader().add(this); // Tells Lingua-Franca to look in the src/main/resources/translations folder
    }
	
    void obtain() {
        Bundle bundle = bundler.load(this, Locale.UK); // Returns messages_en.yml in the src/main/resources/translations folder
		
	String value = bundle.find("path.to.value"); // "value {0}"
	String formatted_value = bundle.find("path.to.value", "formatted"); // "value formatted"
    }
    
}

For more information please see the quick start.


Contributing

Please perform changes and submit pull requests from the master branch. Please adhere to the apparent style of the code you are editing.