Skip to content

Commit 33cb043

Browse files
committed
Add support for translations in actual addons
1 parent 7b61f00 commit 33cb043

File tree

13 files changed

+112
-7
lines changed

13 files changed

+112
-7
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ build/Release
3636
node_modules/
3737
jspm_packages/
3838

39+
# Include node modules used in tests
40+
!fixtures/**/node_modules
41+
3942
# TypeScript v1 declaration files
4043
typings/
4144

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ To prevent that from happening you can configure a `whitelist`, which accepts an
4343
array of regular expressions that will be checked when looking for unused
4444
translations.
4545

46+
### `externalPaths`
47+
48+
If your application uses translations provided by (external) addons, then those
49+
translations will show up as missing by default. In order to include such translations,
50+
you can define `externalPaths` in the configuration file as follows:
51+
52+
```js
53+
export default {
54+
externalPaths: ['my-addon'],
55+
};
56+
```
57+
58+
This example will try to find translation files in `node_modules/my-addon/translations`.
59+
Patterns supported by [`globby`](https://www.npmjs.com/package/globby) are also
60+
possible here, e.g. this:
61+
```js
62+
externalPaths: ['@*/*']
63+
```
64+
will look up translations in scoped addons like `node_modules/@company/scoped-addon/translations`.
65+
4666
### `--fix`
4767
If your application has a lot of unused translations you can run the command with
4868
the `--fix` to remove them. Remember to double check your translations as dynamic

__snapshots__/test.js.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ exports[`Test Fixtures emblem 1`] = `
4444

4545
exports[`Test Fixtures emblem 2`] = `Map {}`;
4646

47+
exports[`Test Fixtures external-addon-translations 1`] = `
48+
"[1/4] 🔍 Finding JS and HBS files...
49+
[2/4] 🔍 Searching for translations keys in JS and HBS files...
50+
[3/4] ⚙️ Checking for unused translations...
51+
[4/4] ⚙️ Checking for missing translations...
52+
53+
👏 No unused translations were found!
54+
55+
⚠️ Found 1 missing translations!
56+
57+
- other-external-addon.used-by-app-translation (used in app/templates/application.hbs)
58+
"
59+
`;
60+
61+
exports[`Test Fixtures external-addon-translations 2`] = `Map {}`;
62+
4763
exports[`Test Fixtures in-repo-translations 1`] = `
4864
"[1/4] 🔍 Finding JS and HBS files...
4965
[2/4] 🔍 Searching for translations keys in JS and HBS files...
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Controller from '@ember/controller';
2+
3+
export default class ApplicationController extends Controller {
4+
get foo() {
5+
return this.intl.t('js-translation');
6+
}
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{t "hbs-translation"}}
2+
{{t "external-addon.used-by-app-translation"}}
3+
{{t "other-external-addon.used-by-app-translation"}}
4+
{{t "company.scoped-addon.used-by-app-translation"}}

fixtures/external-addon-translations/node_modules/@company/scoped-addon/templates/application.hbs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/external-addon-translations/node_modules/@company/scoped-addon/translations/en.yaml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/external-addon-translations/node_modules/external-addon/templates/application.hbs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/external-addon-translations/node_modules/external-addon/translations/en.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/external-addon-translations/node_modules/other-external-addon/translations/en.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)