New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ember-intl/decorators

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ember-intl/decorators

Decorators for using ember-intl with ES6 class syntax

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
82
increased by20.59%
Maintainers
4
Weekly downloads
 
Created
Source

@ember-intl/decorators

CI npm version Download Total Ember Observer Score ![Ember Versions](https://img.shields.io/badge/Ember.js Versions-^3.12-brightgreen.svg) code style: prettier dependencies devDependencies

This addon provides utility decorators to use ember-intl with ES6 class syntax.

Installation

Install ember-intl and @ember-intl/decorators:

ember install ember-intl @ember-intl/decorators

Usage

@t

Decorator version of the ember-intl translationMacro. Implicitly injects the intl service. Creates a computed property that depends on the current locale and any keys that you pass as the second parameter.

import Component from '@ember/component';
import { t } from '@ember-intl/decorators';

class ExampleComponent extends Component {
  name = 'Tom';

  @t('messages.welcome', { firstName: 'name' }) message; // => 'Welcome, Tom!'
}

Using the raw helper you can pass static values as well:

import Component from '@ember/component';
import { t, raw } from '@ember-intl/decorators';

class ExampleComponent extends Component {
  name = 'Tom';

  @t('messages.greeting', {
    firstName: 'name',
    timeOfDay: raw('morning')
  })
  message; // => 'Good morning, Tom!'
}

@intl

A generic decorator that implicitly injects the intl service and creates a computed property that depends on the current locale and any further optional dependent keys passed to the decorator.

The decorated method or (arrow) function is bound to the class instance the decorator is used on and invoked with two parameters:

  • intl: the intl service, that you can use to call any method on
  • propertyKey: the name of the decorated property

The return value is used as the value of the computed property.

import Component from '@ember/component';
import { intl } from '@ember-intl/decorators';

class ExampleComponent extends Component {
  amount = 1.23;
  currency = 'EUR';

  @intl('amount', 'currency')
  formatted = intl =>
    intl.formatNumber(this.amount, {
      style: 'currency',
      currency: this.currency
    });
}

Keywords

FAQs

Package last updated on 03 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc