-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This Java library is an implementation of Mozillas Fluent that is a family of localization specifications. It is an implementation that tries to have as much compatibility with the project but also have some little extra features.
Instead of other translation paradigms like the .properties
in Java, Fluent tries to go away from simple key-value pairs and with that build something that is more reactive to the parameters that were given.
"Software localization has been dominated by an outdated paradigm: the translation is just a dictionary of strings which map one-to-one to the English (en-US) copy. This paradigm is unfair and limiting to languages with grammars more complex than English. For any grammatical feature not supported by English, a special case must be added to the source code, leaking logic into all translations. Furthermore, creating good UIs which depend on multiple external arguments is hard and requires the developer to understand the grammar of the languages the product targets." - Project Fluent
This means that when you use Fluent, there is always a single Fluent translation file for Language X that has some keys and some values. In these Values there can be things like placeables that allow the message to make something interactive. So a language file could look like this:
# Simple things are simple.
hello-user = Hello, {$userName}!
# Complex things are possible.
shared-photos =
{$userName} {$photoCount ->
[one] added a new photo
*[other] added {$photoCount} new photos
} to {$userGender ->
[male] his stream
[female] her stream
*[other] their stream
}.
In this example there are two keys (hello-user
and shared-photos
). All of the stuff that starts with a #
is a comment.
If in this example the key hello-user
is getting called with the parameter of userName = Max
it would return the String Hello, Max!
.