Coder Social home page Coder Social logo

java.properties.js's Introduction

java.properties.js

Build Status Code Climate

Converts a string with the java properties file format to a Javascript Object

It can be used client-side and server-side.

This lib can be useful for i18n-properties files.

Installation

bower install java.properties.js

or when using npm:

npm install java.properties.js

Module Support

Note the dist directory has multiple module formats, use whatever works best for you.

  • AMD

    define(['java.properties'], function(propertiesToObject) {});

  • Node.JS (CJS)

    var propertiesToObject = require('java.properties.js').default

  • Globals

    window.javaProperties

API

This lib is only one method which is capable of converting a string in java.properties format to a Javascript Object

# i18n messages
user.edit.title             = Edit User
user.followers.title.one    = One Follower
user.followers.title.other  = All {{count}} Followers
button.add_user.title       = Add a user
button.add_user.text        = Add
button.add_user.disabled    = Saving...
# You can add comments like this,
! or with comments
longvalue                   = You can even use \
                                multi-line strings!
var translations = propertiesToObject(messages);
// result
{
  "user": {
    "edit": {
      "title": "Edit user"
    },
    "followers": {
      "title": {
        "one": "One Follower",
        "other": "All {{count}} Followers"
      }
    }
  },
  "button": {
    "add_user": {
      "title": "Add a user",
      "text": "Add",
      "disabled": "Saving..."
    }
  },
  "longvalue": "You can even use multi-line strings!"
}

java.properties.js's People

Contributors

willemdewit avatar

Watchers

James Cloos avatar Andy Clark 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.