mainmatter / ember-intl-analyzer

Find missing or unused translations in your Ember.js projects
MIT License
48 stars 14 forks source link

Allow extending a list of translation helpers for AST analysis #615

Closed lolmaus closed 8 months ago

lolmaus commented 1 year ago

In a project, I have implemented a t-error helper to standardize error handling:

Before:

{{#if (eq error.status 403)}}
  {{t "errors.forbidden"}}
{{else if (gte error.status 400}}
  {{t "errors.server-failure"}}
{{else}}
  {{t "my-component.error-message"}}
{{/if}}

After:

{{t-error error "my-component.error-message"}}

Unfortunately, this forces me to add all fallback keys to ember-intl-analyzer whitelist.

I would like to configure ember-intl-analyzer to recognize my t-error helper. I imagine something like this:

export default {
  whitelist: [
    /^[^.]+\.warnings\.[^.]+$/,
  ],
  helpers: ['t', 't-error'],
};

Is it something we want to support?

PS Please note this should not be sensitive to argument order.

CC @nickschot

Mikek2252 commented 8 months ago

This is now available to use in 4.6.0