diff --git a/app/routes/app.ts b/app/routes/app.ts index b284cd6..24640be 100644 --- a/app/routes/app.ts +++ b/app/routes/app.ts @@ -21,7 +21,9 @@ export default class AppRoute extends Route { } async model({ locale }: { locale: string }) { - this.intl.locale = locale === 'en-us' ? locale : [locale, 'en-us']; + if (this.intl.locale[0] !== locale) { + this.intl.locale = locale === 'en-us' ? locale : [locale, 'en-us']; + } // No await here, let's the loading happen & await for it in generator route this.harfbuzz.loadWASM(); this.fontManager.loadFont(); diff --git a/app/routes/index.ts b/app/routes/index.ts index f783df6..af593f1 100644 --- a/app/routes/index.ts +++ b/app/routes/index.ts @@ -1,11 +1,13 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; +import RouterService from '@ember/routing/router-service'; import IntlService from 'ember-intl/services/intl'; export default class IndexRoute extends Route { @service declare intl: IntlService; + @service declare router: RouterService; async model() { - this.transitionTo('app.index', this.intl.locale[0]); + this.router.transitionTo('app.index', this.intl.locale[0]); } } diff --git a/tests/integration/components/lang-switcher-test.ts b/tests/integration/components/lang-switcher-test.ts index cc84eb5..ee59819 100644 --- a/tests/integration/components/lang-switcher-test.ts +++ b/tests/integration/components/lang-switcher-test.ts @@ -10,11 +10,13 @@ const { APP: { availableLanguages }, } = config; import waitCalciteReady from 'text2stl/tests/helpers/wait-calcite-ready'; +import { setupIntl } from 'ember-intl/test-support'; import type IntlService from 'ember-intl/services/intl'; module('Integration | Component | lang-switcher', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); hooks.afterEach(function () { (this.owner.lookup('service:intl') as IntlService).locale = 'en-us'; diff --git a/tests/integration/components/settings-form-test.ts b/tests/integration/components/settings-form-test.ts index e59d172..a1e3244 100644 --- a/tests/integration/components/settings-form-test.ts +++ b/tests/integration/components/settings-form-test.ts @@ -5,9 +5,11 @@ import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setComponentTemplate } from '@ember/component'; import { ModelType } from 'text2stl/services/text-maker'; +import { setupIntl } from 'ember-intl/test-support'; module('Integration | Component | settings-form', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); test('it renders', async function (assert) { class SettingsFormFont extends Component {} diff --git a/tests/integration/components/settings-form/font-test.ts b/tests/integration/components/settings-form/font-test.ts index 024c53a..f041481 100644 --- a/tests/integration/components/settings-form/font-test.ts +++ b/tests/integration/components/settings-form/font-test.ts @@ -6,9 +6,11 @@ import { setComponentTemplate } from '@ember/component'; import { tracked } from '@glimmer/tracking'; import templateOnly from '@ember/component/template-only'; import waitCalciteReady from 'text2stl/tests/helpers/wait-calcite-ready'; +import { setupIntl } from 'ember-intl/test-support'; module('Integration | Component | settings-form/font', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); test('it renders', async function (assert) { // mock the FontPicker diff --git a/tests/integration/components/settings-form/handle-test.ts b/tests/integration/components/settings-form/handle-test.ts index bf265fd..262be0e 100644 --- a/tests/integration/components/settings-form/handle-test.ts +++ b/tests/integration/components/settings-form/handle-test.ts @@ -10,9 +10,11 @@ import TextMakerSettings from 'text2stl/models/text-maker-settings'; import { ModelType } from 'text2stl/services/text-maker'; import fillCalciteInput from 'text2stl/tests/helpers/fill-calcite-input'; import waitCalciteReady from 'text2stl/tests/helpers/wait-calcite-ready'; +import { setupIntl } from 'ember-intl/test-support'; module('Integration | Component | advanced-settings-form/handle', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); test('it renders', async function (assert) { const model = new TextMakerSettings({ diff --git a/tests/integration/components/settings-form/support-test.ts b/tests/integration/components/settings-form/support-test.ts index 895cc42..7a25644 100644 --- a/tests/integration/components/settings-form/support-test.ts +++ b/tests/integration/components/settings-form/support-test.ts @@ -9,9 +9,11 @@ const { import TextMakerSettings from 'text2stl/models/text-maker-settings'; import { ModelType } from 'text2stl/services/text-maker'; import fillCalciteInput from 'text2stl/tests/helpers/fill-calcite-input'; +import { setupIntl } from 'ember-intl/test-support'; module('Integration | Component | advanced-settings-form/support', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); test('it renders', async function (assert) { const model = new TextMakerSettings({ diff --git a/tests/integration/components/settings-form/text-test.ts b/tests/integration/components/settings-form/text-test.ts index d1239a0..8d16691 100644 --- a/tests/integration/components/settings-form/text-test.ts +++ b/tests/integration/components/settings-form/text-test.ts @@ -8,11 +8,12 @@ const { } = config; import TextMakerSettings from 'text2stl/models/text-maker-settings'; import { ModelType } from 'text2stl/services/text-maker'; - import fillCalciteInput from 'text2stl/tests/helpers/fill-calcite-input'; +import { setupIntl } from 'ember-intl/test-support'; module('Integration | Component | settings-form/text', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); test('it renders', async function (assert) { const model = new TextMakerSettings({ diff --git a/tests/integration/components/settings-form/type-select-test.ts b/tests/integration/components/settings-form/type-select-test.ts index 409ea05..7017b7a 100644 --- a/tests/integration/components/settings-form/type-select-test.ts +++ b/tests/integration/components/settings-form/type-select-test.ts @@ -9,9 +9,11 @@ const { import TextMakerSettings from 'text2stl/models/text-maker-settings'; import { ModelType } from 'text2stl/services/text-maker'; import wait from 'text2stl/tests/helpers/wait'; +import { setupIntl } from 'ember-intl/test-support'; module('Integration | Component | settings-form/select-type', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); test('it renders', async function (assert) { const model = new TextMakerSettings({ diff --git a/tests/integration/components/three-preview-test.ts b/tests/integration/components/three-preview-test.ts index 0723049..6ac562e 100644 --- a/tests/integration/components/three-preview-test.ts +++ b/tests/integration/components/three-preview-test.ts @@ -4,9 +4,11 @@ import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setComponentTemplate } from '@ember/component'; import Component from '@glimmer/component'; +import { setupIntl } from 'ember-intl/test-support'; module('Integration | Component | three-preview', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); test('it renders', async function (assert) { class ThreePreviewRenderer extends Component {} diff --git a/tests/integration/components/three-preview/size-test.ts b/tests/integration/components/three-preview/size-test.ts index 0313d66..82ff929 100644 --- a/tests/integration/components/three-preview/size-test.ts +++ b/tests/integration/components/three-preview/size-test.ts @@ -3,9 +3,11 @@ import { setupRenderingTest } from 'ember-qunit'; import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { Mesh, BoxGeometry } from 'three'; +import { setupIntl } from 'ember-intl/test-support'; module('Integration | Component | tree-preview/size', function (hooks) { setupRenderingTest(hooks); + setupIntl(hooks); test('it renders nothing when no mesh is specified', async function (assert) { await render(hbs``);