Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ggiamarchi/i18n.generator
https://github.com/ggiamarchi/i18n.generator
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ggiamarchi/i18n.generator
- Owner: ggiamarchi
- License: apache-2.0
- Created: 2013-03-13T09:59:22.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-16T15:36:00.000Z (over 11 years ago)
- Last Synced: 2024-10-05T18:01:20.512Z (3 months ago)
- Language: Java
- Size: 516 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/ggiamarchi/i18n.generator.png?branch=master)](https://travis-ci.org/ggiamarchi/i18n.generator)
# I18N Generator #
* Abstract
* Quickstart
* User guide
### Abstract ###
This project provides code generator for Java that produces class with methods that match i18n properties. Calling
methods on the generated interface rather that reference string property keys in source code prevents to reference a
non-existing key.For instance, assume that we have two java property files. The fist one, `messages.properties`, provides english messages
(the default language in this case) for an application```
hello.world=Hello everybody
hello.to.somebody=Hello {0} {1}
```And the second one, `messages_fr_FR.properties`, provides the same messages in french
```
hello.world=Bonjour tout le monde
hello.to.somebody=Bonjour {0} {1}
```The purpose of the plugin is to generate a java interface (and its implementation, as we'll see later) with methods
that match properties defined in `*.properties` files. The generated interface looks something like this one```java
public interface Messages {String hello_world();
String hello_to_somebody(String arg0, String arg1);
}
```An implementation class for this interface is generated as well. The goal of this implementation is to return the value
corresponding to the right language for each interface's method. "The right language" means the one according to either
the defaut locale or the one given by a LocaleProvider, an interface that can be implemented to compute the locale on
the fly at runtime. For example, you would like to get the locale from the user session in case of a web application.```java
public class MessagesImpl implements Messages {@Override
public String hello_world() {
// ...
}
@Override
public String hello_to_somebody(String arg0, String arg1) {
// ...
}
// Some technical stuffs...
}
```Then, you finally just have to use these generated class in you application like any another. For example,
```java
Messages messages = ... // Instanciate the MessagesImpl class the way you want. With the new keywork, a Spring lookup, ...
String helloMe = messages.hello_to_somebody("Guillaume", "Giamarchi");
```That's all folks !
### Quickstart ###
_(Available soon)_
### User guide ###
_(Available soon)_