Code Monkey home page Code Monkey logo

ember-cli-java-properties-to-object's Introduction

ember-cli-java-properties-to-object

Converts java properties files to a ES6 module which exports the object version.

This is copied from https://github.com/gdub22/ember-cli-less. All credits to the author.

Installation

npm install --save-dev ember-cli-java-properties-to-object

Usage

This addon will compile *.properties files into ES6 modules which export the POJO version of it.
This can be used for converting properties files which contain i18n messages.

# 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...
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..."
    }
  }
}

The result can then be used in ember-cli-i18n

References

ember-cli-java-properties-to-object's People

Contributors

willemdewit avatar ember-tomster avatar

Watchers

James Cloos avatar  avatar

Forkers

bpcrao

ember-cli-java-properties-to-object's Issues

Placing a properties file inside the app/ folder crashes the app with ES6/AMD issues.

Using ember cli 2.9 the generated ES6 syntax files will crash the ember application with a syntax exception.
Steps to Repeat

  1. run ember install ember-cli-java-properties-to-object

  2. Create a file /app/locales/en/loc.properties having a single line: foo=bar

  3. checking the generated js app code you'll find a lost "ES6" code piece between lots of "AMD" style code:

    define('ocst/instance-initializers/ember-i18n',` ['exports', 'ember-i18n/instance-initializers/ember-i18n'], function (exports, _emberI18nInstanceInitializersEmberI18n) {
    exports['default'] = _emberI18nInstanceInitializersEmberI18n['default'];
    });
    // here comes the generated code
    export default {"foo":"bar"}
    define("ocst/locales/en/config", ...

Expected

  1. Either the generated file is placed under /app/locales/en/loc.properties.js OR

  2. generate AMD style syntax, whereby the generated code would look like so:
    define('ocst/locales/en/loc.properties',` ['exports', 'ocst/locales/en/loc.properties'], function (exports) {
    exports['default'] = {"foo":"bar"};
    });

unexpected_token

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.