L20n is an open source, JavaScript localization framework from Mozilla. It is designed to be very expressive along with several features such as adapting to Screen sizes, good separation of concerns, graceful handling of pluralization, support for default when there are multiple variants, and more.
Staś Małolepszy explains the motivation behind the project -
Localizing Mozilla projects has taught us that as many as 90-95% of messages found in the UI are simple key-value pairs that won't require any advanced knowledge of L20n's features.
So why develop L20n at all? Because it's the remaining 5% that make or break the UI of your app. They're too important to ignore and they are responsible for the experience of your user.
As such, the project tries to keep simple scenarios simple, but also supports complex localizations when needed.
Below are some interesting features of L20n -
- Expressiveness - L20n has support for interpolations (to build more complex entities), pluralizations, handling of grammatical cases, having multiple variants of the same entity, and so on, which combine to create a very expressive format.
- Responsiveness to screen sizes - you can name various screen sizes and then have different variants of the entities targeted for these specific screen sizes
- Good separation of concerns - localization related complexities can be isolated in the language under consideration without affecting other languages used in the app or even the app source code.
- Non-blocking, secure API in addition to the ability to bind HTML elements to make them localizable
A simple but powerful concept that L20n introduces is the concept of Defaults - this allows you to define multiple variants for an entity but also define a default value in case any specific variant is not asked for. This enables translators to progressively tweak their content and even add more variants, while ensuring that existing code using these entities are not affected (by just choosing a default). This is what also allows different localizations to have different degrees of complexity without having to complicate all other localizations.
Here are a few resources to learn more about the project -
- The project ReadMe
- A demo project that shows how an HTML file can be localized using L20n
- Step-by-step tutorial introducing various concepts
- Documentation
- A Set of FAQs and Answers
L20n has been in development since 2012 and the release candidate for 1.0 has been out since November 2013.