Ember-intl: `IntlService#lookup()` return value changed in v5

Created on 4 Aug 2020  ·  6Comments  ·  Source: ember-intl/ember-intl

https://ember-intl.github.io/ember-intl/docs/guide/service-api#lookup-translationkey-string-optionallocale-string-array-string-optionaloptions-object-string-undefined

We're currently upgrading our app from v4 to v5 and I found that the return value of IntlService#lookup() has changed.

https://github.com/ember-intl/ember-intl/blob/322d325733146b71d77c5aa6d1724ed514f0b07c/addon/services/intl.js#L116-L136

It used to return the raw translation string, but now it returns an array like:

[{ type: 0, value: "Some translation" }]

Was this change intentional? I don't think it is.

bug

All 6 comments

Hm, looking at IntlService#t() it _does_ seem intentional, as an AST is now used internally.

https://github.com/ember-intl/ember-intl/blob/322d325733146b71d77c5aa6d1724ed514f0b07c/addon/services/intl.js#L147-L174

I think we need to document this.

We should fix. It wasn't intentional and thanks for bringing it to my attention.

The internal change was intentional for perf reasons but we should be able to keep it so the public lookup method returns the original string translation and not the AST object. Unfortunately, I unknowingly let this bleed into the public API.

Some side context, I haven't worked in Ember in a couple years now and am relying entirely on the Ember community to report these bugs as I no longer "dogfood" my own addons. Some things will slip through so I'm thankful to have every early adopter raise these issues ❤

Some side context, I haven't worked in Ember in a couple years now and am relying entirely on the Ember community to report these bugs as I no longer "dogfood" my own addons. Some things will slip through so I'm thankful to have every early adopter raise these issues ❤

I'm so grateful for you still putting so much work into this great addon. 💖

I suggest we add a private (or public?) lookupAST() method and let lookup() return the raw string again. Or what would you suggest?

I suggest we add a private (or public?) lookupAST() method and let lookup() return the raw string again. Or what would you suggest?

Agreed and private makes sense since I don't think it makes sense to expose publicly right now.

Fixed in v5.4.0

Awesome @jasonmit 🎉

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sly7-7 picture sly7-7  ·  3Comments

gossi picture gossi  ·  5Comments

dbendaou picture dbendaou  ·  4Comments

szneba picture szneba  ·  5Comments

Kilowhisky picture Kilowhisky  ·  4Comments