Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates to ember-cli 3.22 and Ember Octane.
The main change is refactoring everything to ES6 classes. This required a few adjustments, as native ES6 classes have slightly different timing semantics for the constructor, which don't play well with extending a base class - so the current way of defining
availableLocales
does not work there properly.To accomodate this, the configuration has been moved to
config/environment.js
(where we already had a single configuration option forjsonPath
). You can now configure this addon like this:You should not need to extend from the service anymore in your application.
Nothing should have to change in your application code. The usage of the service/helpers/component remains the same.
As this is a breaking change, I would release it as 5.0.0. Migration should be relatively straightforward.
Other notable changes in the move to Octane:
<GetText>
- this is an internal change, the usage did not change at all.autoInitialize
default tofalse
. In most scenarios you want to manually set the locale in the application route'sbeforeModel
hook or similar, in order to ensure that the locale file is loaded before the application is shown.ember-l10n/test-helpers.js
file is removed. It is not needed anymore for quite some time.You might also need to adjust something in your tests, if you relied on overwriting some properties of the l10n-service there. You can do so now like this:
In detail explanation on the timing semantics of ES6 classes vs. classic Ember classes
A short explanation on why the changes to the configuration where necessary in the move to ES6 classes follows.
Previously, we had an
init
hook like this:Now, the initial assumption would be that you can simply refactor this to:
And at first, that does work as expected. However, this breaks when you try to overwrite default values on the class. Think this base class:
And this extended class:
Because of the way native ES6 constructors work, this will not work as expected. The reason is that the above code is internally resolved to this:
Basically, anything set on an extended class will not be available in the base-class constructor, as the constructor of the base class is called first, and only then the "changes" of the extended class are applied. This is not Ember-specific but the way ES6 classes work generally.
This is the reason for moving the configuration out of the extended service into
config/environment.js
, which is probably cleaner anyhow (and also allows easily setting different settings for tests etc.).