GithubHelp home page GithubHelp logo

mifrill / ember-i18n-errors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cibernox/ember-i18n-errors

0.0 2.0 0.0 19 KB

Extension to ember-i18n for translating error messages within the route hierarchy

License: MIT License

JavaScript 81.90% HTML 18.10%

ember-i18n-errors's Introduction

Ember-i18n-errors

This addon leverages ember-i18n but for the specific purpose of localize error messages.

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

This addon requires Ember.js 1.13+ and ember-i18n 4.1+

  • ember install ember-i18n-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.

ember-i18n-errors's People

Contributors

cibernox avatar ember-tomster avatar jasonmit avatar

Watchers

 avatar  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.