GithubHelp home page GithubHelp logo

mifrill / ember-intl-errors Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 304 KB

ember-i18n-errors implementation with ember-intl service usage

License: MIT License

JavaScript 87.26% HTML 11.42% Handlebars 1.33%

ember-intl-errors's Introduction

ember-intl-errors

This addon is ember-i18n-errors implementation for ember-intl.

It adds to your app a handy helper {{t-error error}} for translating errors in the context of the current route, but also takes advantage of Ember's route nesting to lookup translations in fallback on parent routes.

Installation

ember install ember-intl-errors

Usage

This is better explained with an example.

Let's say we have a validation error with the mandatory shape ({ attribute: 'email', message: 'invalid' }) and some nested routes with this structure:

parent
└── child
    └── grandchild

If within the grandchild.hbs template we use the helper {{t-error error}} the helper will try to find the most especific translation key for it based on the route hierarchy.

It follows a set of conventions very similar to how rails-i18n handles ActiveRecord errors.

The fallback chain for that error will be:

parent.child.grandchild.errors.email.invalid
parent.child.grandchild.errors.invalid
parent.child.errors.email.invalid
parent.child.errors.invalid
parent.errors.email.invalid
parent.errors.invalid
errors.email.invalid
errors.invalid

If none of those keys is defined in your translations the missing translation message will point you to the most specific translation: Missing translation: parent.child.grandchild.errors.email.invalid.

Contributing

Installation

  • git clone [email protected]:Mifrill/ember-intl-errors.git
  • cd ember-intl-errors
  • npm install

Linting

  • yarn lint:js
  • yarn lint:js -- --fix

Running tests

  • ember test – Runs the test suite on the current Ember version
  • ember test --server – Runs the test suite in "watch mode"
  • ember try:each – Runs the test suite against multiple Ember versions

Running the dummy application

For more information on using ember-cli, visit https://ember-cli.com/.

License

This project is licensed under the MIT License.

ember-intl-errors's People

Contributors

mifrill avatar ember-tomster avatar

Watchers

James Cloos avatar  avatar  avatar

ember-intl-errors's Issues

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.