Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

feat(intl): add @intl decorator #66

Merged
merged 6 commits into from
Nov 29, 2018
Merged

feat(intl): add @intl decorator #66

merged 6 commits into from
Nov 29, 2018

Conversation

buschtoens
Copy link
Member

@buschtoens buschtoens commented Nov 28, 2018

Closes ember-intl/ember-intl#392 (comment).

From the README.md:

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
    });
}

@buschtoens
Copy link
Member Author

buschtoens commented Nov 28, 2018

Depends on ember-decorators/ember-decorators#318 for legacy decorators compatibility, which we don't explicitly test for yet. One could argue that this is responsibility of @ember-decorators/utils (and they do test for it), but adding some more tests here would not hurt, I guess.

@buschtoens
Copy link
Member Author

Depends on ember-intl/ember-intl#708

@jasonmit jasonmit merged commit 703906e into master Nov 29, 2018
@delete-merged-branch delete-merged-branch bot deleted the feat/intl-decorator branch November 29, 2018 09:16
buschtoens pushed a commit that referenced this pull request Nov 29, 2018
# [0.2.0](v0.1.0...v0.2.0) (2018-11-29)

### Features

* **intl:** add [@intl](https://github.com/intl) decorator ([#66](#66)) ([703906e](703906e))
@buschtoens
Copy link
Member Author

🎉 This PR is included in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

buschtoens pushed a commit that referenced this pull request Nov 29, 2018
## [0.2.1](v0.2.0...v0.2.1) (2018-11-29)

### Bug Fixes

* **deps:** enforece ember-decorators@^3.1.2 ([de858b5](de858b5)), closes [/github.com//pull/66#issuecomment-442417044](https://github.com//github.com/ember-intl/decorators/pull/66/issues/issuecomment-442417044)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants