Skip to content

chisui/translate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

translate

travis badgeCode Coverage

translate is a functional java translation library.

To include it in your project using maven add the dependency:

<dependency>
    <groupId>com.github.chisui.translate</groupId>
    <artifactId>translate</artifactId>
    <version>0.1.0</version>
</dependency>

Usage

The two core components of this library are the Translator and TranslationHint. A TranslationHint provides information to a Translator to create a translation.

Create a Translator

Translator translator = Translator.of(
		MessageLookup.of(MessageSource.ofResouceBundle("translations")),
		Format.ofMessageFormat());

This creates a Translator that looks for in the ResourceBundle "translations" and formats messages using MessageFormat.

Create a TranslationHint

TranslationHint hint = TranslationHint
	.of("key")
	.withArguments(arg0, arg1, ...)
	.withFallback("fallback {0} {1}");

Translate the hint

String translation = translator.translate(hint);

About

java translation library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages