question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question - Difference using `t` helper and `intl.t` from the Service

See original GitHub issue
  • I have searched the issues of this repo and believe that this is not a duplicate

Environment

  • Ember Version: 3.16.10
  • Ember CLI Version: 3.16.2
  • Ember Intl Version: 4.4.1

Question

Hello there, I have a small question.

I am wondering, is there a difference between using t macro helper and intl.t from the Service?

https://ember-intl.github.io/ember-intl/docs/guide/translating-text#t

import { t } from 'ember-intl';

export default class ... {
  title = t('my.key');
});

https://ember-intl.github.io/ember-intl/docs/guide/service-api#t-translationkey-string-optionaloptions-object-string-safestring

export default class ... {
  @service intl;

  constructor() {
    title = this.intl.t('my.key');
  }
});

For some cases I need @computed('intl.locale') so obviously the Service will be injected and I will use this.intl.t().

Thanks for your explanation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MrChocolatinecommented, Sep 4, 2020

That wouldn’t work, because you’re returning the computed property macro, not the value it would resolve to.

Ah yes, right. It seems I easily forget it is a computed property macro so indeed it won’t return the value.

Again many thanks, great explanations. It also helped other JS dev of my team.

0reactions
jasonmitcommented, Sep 4, 2020

Ensure that using this.intl.t(‘…’) in an auto-tracking context correctly entangles the locale as a dependency, so that changing the locale invalidates the getter

I believe there was an attempt to resolve this: https://github.com/ember-intl/ember-intl/pull/1340

Landed in v5.2.0, is that not working?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Voice Over Internet Protocol (VoIP)
IP-Enabled Services Voice over Internet Protocol (VoIP), is a technology that allows you to make voice calls using a broadband Internet connection instead ......
Read more >
FAQs on the 2020 Form W-4 | Internal Revenue Service
Frequently asked questions on the 2020 Form W-4. ... Are all employees required to furnish a new Form W-4? No. Employees who have...
Read more >
Job Application FAQ - CalCareers - CA.gov
Typically, State departments hire Student Assistants using two different options. Option #1: The department advertises their own vacancies and hires their ...
Read more >
Frequently asked questions - UNRWA
Palestine refugees registered with the Agency are eligible to access its services within the UNRWA areas of operations (Lebanon, Jordan, Syria, ...
Read more >
Questions and Answers: The IMF's response to COVID-19
What is the Fund doing to help countries during the coronavirus crisis? ... Shouldn't the IMF ask a country's external creditors to forgive...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found