ember-intl / ember-intl

Internationalization for Ember projects
https://ember-intl.github.io
MIT License
434 stars 167 forks source link

Cannot silence missing translations output on build #1908

Closed Techn1x closed 1 week ago

Techn1x commented 3 weeks ago

I have errorOnMissingTranslations: false in my config. While it (correctly) doesn't error, it forces the missing translations to appear in output.

eg

[ember-intl] "promo.msUpsell.intro" was not found in "en-au", "en-ca", "en-gb", "en-us", "ko", "zh"
[ember-intl] "promo.msUpsell.getStarted" was not found in "en-au", "en-ca", "en-gb", "en-us", "ko", "zh"
[ember-intl] "promo.msUpsell.settingUp" was not found in "en-au", "en-ca", "en-gb", "en-us", "ko", "zh"
[ember-intl] "promo.msUpsell.youCanAlso" was not found in "en-au", "en-ca", "en-gb", "en-us", "ko", "zh"
[ember-intl] "promo.msUpsell.copyClasses" was not found in "en-au", "en-ca", "en-gb", "en-us", "ko", "zh"
[ember-intl] "promo.msUpsell.ifYouHaveOne" was not found in "en-au", "en-ca", "en-gb", "en-us", "ko", "zh"

The relevant code is here; https://github.com/ember-intl/ember-intl/blob/215f867e467a76dfacdc2b0b002146d7dece6dde/packages/ember-intl/lib/broccoli/translation-reducer/index.js#L175-L190

In theory, I just need to set verbose: false in my options. I tried this, however it is not used - options.verbose is only defined by the following line, where this.isSilent seems to be a dead reference, so verbose is always true https://github.com/ember-intl/ember-intl/blob/215f867e467a76dfacdc2b0b002146d7dece6dde/packages/ember-intl/index.js#L118


I'd be happy to put a PR together, likely a simple fix, but I am not sure the approach we want. Do we want to expose verbose as a configurable option for users, with default as false? Or something else?

ijlee2 commented 3 weeks ago

@Techn1x I've seen similar log messages in my project, but didn't get to look into the cause. I'm glad that you got to a bit.

Feel free to try out possible solutions using the "docs" projects in the docs folder, and create a pull request if you find a good solution. I'll be on vacation and won't be able to look into the issue for some time. If you need the log messages gone soon, I'd suggest patching ember-intl for now.

I think, going forward, we'll want to replace config/ember-intl.js with @embroider/macros and reduce the number of configuration options (i.e. let's try to avoid allowing configuring verbose). Due to API changes in the intl service introduced in v7.0.0, there may be already some that have no effect and can be removed.

Techn1x commented 3 weeks ago

Thanks, will find some time to make that PR.

Yeah I patched my project in the meantime 👍

Techn1x commented 2 weeks ago

PR here https://github.com/ember-intl/ember-intl/pull/1909