Skip to content

Commit 8eb8ea8

Browse files
committed
Add support for translations in in-repo addons
1 parent 2fca43f commit 8eb8ea8

File tree

12 files changed

+109
-3
lines changed

12 files changed

+109
-3
lines changed

__snapshots__/test.js.snap

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

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

47+
exports[`Test Fixtures in-repo-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+
⚠️ Found 1 unused translations!
54+
You can use --fix to remove all unused translations.
55+
56+
- in-repo-addon.unused (used in lib/in-repo-addon/translations/en.yaml)
57+
58+
⚠️ Found 2 missing translations!
59+
60+
- translation-missing-in-addon (used in lib/in-repo-addon/addon/templates/addon.hbs)
61+
- translation-missing-in-app (used in lib/in-repo-addon/app/templates/application.hbs)
62+
"
63+
`;
64+
65+
exports[`Test Fixtures in-repo-translations 2`] = `Map {}`;
66+
4767
exports[`Test Fixtures missing-translations 1`] = `
4868
"[1/4] 🔍 Finding JS and HBS files...
4969
[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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{t "hbs-translation"}}
2+
{{t "in-repo-addon.translation-outside-addon"}}
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 AddonController extends Controller {
4+
get foo() {
5+
return this.intl.t('in-repo-addon.addon.js-translation');
6+
}
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{t "in-repo-addon.addon.hbs-translation"}}
2+
{{t "translation-outside-app-in-addon"}}
3+
{{t "translation-missing-in-addon"}}
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('in-repo-addon.app.js-translation');
6+
}
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{t "in-repo-addon.app.hbs-translation"}}
2+
{{t "translation-outside-app-in-app"}}
3+
{{t "translation-missing-in-app"}}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
in-repo-addon:
2+
addon:
3+
hbs-translation: HBS in in-repo addon addon
4+
js-translation: JS in in-repo addon addon
5+
app:
6+
hbs-translation: HBS in in-repo addon app
7+
js-translation: JS in in-repo addon app
8+
translation-outside-addon: This translation is used outside the in-repo addon
9+
unused: This translation is unused
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "in-repo-translations",
3+
"ember-addon": {
4+
"paths": [
5+
"lib/in-repo-addon"
6+
]
7+
}
8+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hbs-translation: HBS!
2+
js-translation: JS!
3+
translation-outside-app-in-addon: This translation is only used in the addon folder of the addon
4+
translation-outside-app-in-app: This translation is only used in the app folder of the addon

0 commit comments

Comments
 (0)