Code Monkey home page Code Monkey logo

bigspin's Introduction

Bigspin

A simple, compact and extensible mechanism to load/get internationalized messages for Java. This library defines a common interface I18N and provides a default implementation based on a property file DefaultI18N.

Why should I use I18N instead of ResourceBundle properly?

Most of well-known internationalization tools are property-file based, as ResourceBundle. However, ResourceBundle has some limitations for use in complex projects. If you want to split your messages in differents files (e.g. base_messages, server_messages, client_messages, log_messages, etc) how to load all of them in one single object? If your project runs in different VMs distributed in several machines, do we need to replicate all files on every machine?

Bigspin aims to solve these problems in one simple way. Here are the feature list:

  • I18N is extensible because you can provide your custom implementation for I18N interface, for instance, load messages from database, caching, etc;
  • You can build a hierarchical set of I18N instances to reuse and redefine some messages;
  • You can define a callback to manage missing resources (ResourceBundle throws MissingResourceException in this case)
  • DefaultI18N is Serializable;

Examples

Loading a local single file:

I18N i18n = new DefaultI18N("base_en_US.properties");
String okText = i18n.get("ok"); // okText = Yes 

Reusing messages stored in different files by creating a hierarchical set of I18N objects:

//create a hierarchical I18N
I18N i18n = new DefaultI18N("base_en_US.properties");
String okText = i18n.get("ok"); // okText = Yes 

i18n = new DefaultI18N("custom_en_US.properties", i18n);
okText = i18n.get("ok"); // okText = Confirm 

If your messages comes from a database instead of property files, you can make your own implementation of I18N. Pull request? =]

License

Created by and copyright GitHub, Inc. Released under the MIT license.

bigspin's People

Contributors

greatjapa avatar marcelo-webradar avatar

Watchers

James Cloos avatar Luiz Gustavo de Souza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.