libgdx/libgdx — pull request #1769 by davebaol (2014-04-26 14:31:55+00:00)
Title: Added I18N support

**Why**
As said [here](https://github.com/libgdx/libgdx/issues/1741) this PR is heavily inspired to ResourceBundle + Control class from java.util.
The main advantage, compared to java ResourceBundle, is that Android 2.2 is fully supported (Control class has been introduced in Android 2.3).
Also, under certain circumstances looks like Android API uses an inconsistent encoding for property files loaded through a ResourceBundle. This issue is fixed.

**What's changed**
The default behavior has changed. Bundles are loaded from file system (actually from `FileType.Internal`) instead of classpath.
This change implies that the bundle name is now expressed as a relative path rather than as a fully qualified class name.
Also, due to the use of relative paths, bundle names are no more unique. For example, the bundle name "foo/bar/Message" on `FileType.Interal` and the same bundle name on `FileType.Local` represent different bundles (it might depend on the specific backend though).

**What's less**
The only missing features are ListResourceBundle and multiple class loaders support.
However both features are pretty much useless for our purposes, so it's not really a big loss.

**What's more**
- Property files with an encoding other than the usual ISO-8859-1 are supported. This feature might be helpful for property files compatible with the 2nd approach below of GWT implementation (GWT I18N expects UTF8 files).
- [Properties in the form of a XML document](http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#loadFromXML%28java.io.InputStream%29) are supported. To load xml properties files from the `FileType.Internal` file system just pass one of the following Control instances to getBundle method:
* `PropertyFileControl.INTERNAL_XML_ONLY` to access xml files only
* `PropertyFileControl.INTERNAL_XML_AND_PROPERTIES` to access xml and key/value pairs files (xml has higher priority)
* `PropertyFileControl.INTERNAL_PROPERTIES_AND_XML` to access xml and key/value pairs files (xml has lower priority)

To load xml files from any file system other than `FileType.Internal` you have to extend `PropertyFileControl` and override its getFormats method accordingly.

**And GWT?**
The GWT implementation is not part of this PR. In fact, it's not yet clear what's the best way to implement this feature.
From a first analysis there seem to be two viable approaches:
- emulating all the java classes used by this PR: `Locale`, `Properties`, `CuncurrentHashMap`, and many others.
- wrapping GWT's localization system, which supports both compile-time conversion of java property files and the search strategy implemented by java ResourceBundle. Especially, looks like the `i18nCreator` script and the `ConstantsWithLookup` interface might be helpful. See the following links:
* http://www.gwtproject.org/doc/latest/DevGuideClientBundle.html
* http://www.gwtproject.org/doc/latest/DevGuideI18n.html#DevGuidePropertiesFiles
* http://www.gwtproject.org/doc/latest/DevGuideI18n.html#DevGuideStaticStringInternationalization
* http://www.gwtproject.org/doc/latest/DevGuideI18nConstants.html

The second approach seems to be more promising.

I'll be on vacation the next days, also I'm not a GWT expert so don't expect a GWT version soon, at least not by me.
Anyone who wants to contribute with ideas or code is welcome, of course.